miykael / atlasreader

Python interface for generating coordinate tables and region labels from statistical MRI images
BSD 3-Clause "New" or "Revised" License
89 stars 31 forks source link

Cluster extent parameter seems to be broken #61

Closed miykael closed 6 years ago

miykael commented 6 years ago

There seems to be a bug in the code on how it handles cluster extent.

For example, if I take this stat_map_01.nii.gz, that has 4 custers with sizes 878, 726, 587 and 1. And if I set the minimum cluster extent at 600, the whole thing crashes with:

Traceback (most recent call last):
  File "/home/line/anaconda3/lib/python3.6/site-packages/nilearn/_utils/niimg_conversions.py", line 428, in concat_niimgs
    first_niimg = check_niimg(next(literator), ensure_ndim=ndim)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/line/anaconda3/bin/atlasreader", line 11, in <module>
    sys.exit(main())
  File "/home/line/anaconda3/lib/python3.6/site-packages/atlasreader/cli.py", line 93, in main
    min_distance=opts.min_distance)
  File "/home/line/anaconda3/lib/python3.6/site-packages/atlasreader/atlasreader.py", line 665, in create_output
    cluster_extent=cluster_extent)
  File "/home/line/anaconda3/lib/python3.6/site-packages/atlasreader/atlasreader.py", line 424, in process_img
    extract_type='connected_components')[0]]
  File "/home/line/anaconda3/lib/python3.6/site-packages/nilearn/regions/region_extractor.py", line 237, in connected_regions
    regions_extracted_img = concat_niimgs(all_regions_imgs)
  File "/home/line/anaconda3/lib/python3.6/site-packages/nilearn/_utils/niimg_conversions.py", line 430, in concat_niimgs
    raise TypeError('Cannot concatenate empty objects')
TypeError: Cannot concatenate empty objects

It seems that this is due to nilearn's connected_regions function here. But it's not clear to me yet, how to solve this issue or what causes it in the first place.

miykael commented 6 years ago

This bug doesn't appear, if all 4 clusters are positive or negative.