mattcieslak / easy_lausanne

Easy creation of Lausanne2008 atlases
Other
24 stars 11 forks source link

"out of bounds" issue running easy_lausanne #9

Open julienbesle opened 4 years ago

julienbesle commented 4 years ago

Hi, I just installed easy_lausanne and tried registering the atlases to a DWI B0 volume, but I run into a python error after a call to mri_label2vol (full output: easy_lausanne_output.txt):

DEBUG    : 2020-05-05 22:10:38,291 : runCmd     : Return Value: 0
Traceback (most recent call last):
  File "/usr/local/bin/easy_lausanne", line 4, in <module>
    __import__('pkg_resources').run_script('Easy-Lausanne==0.5', 'easy_lausanne')
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 719, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 1511, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python2.7/dist-packages/Easy_Lausanne-0.5-py2.7.egg/EGG-INFO/scripts/easy_lausanne", line 86, in <module>

  File "build/bdist.linux-x86_64/egg/easy_lausanne/maskcreation.py", line 274, in create_roi
IndexError: index 256 is out of bounds for axis 2 with size 256

I've tried three subjects and several different B0 volumes for a given subject (different resolutions and different grids). For one subject, the error does not occur, but for the other two, the error always occurs after processing the same label, irrespective of which B0 volume I use, but after different labels for different subjects.

I'm using freesurfer v 6.0.0.

Can anyone help? Alternatively, is there any other way to get the Lausanne 2008 atlas registered with freesurfer subjects? Thanks

julienbesle commented 4 years ago

I think I've identified the issue: I'm using freesurfer parcellations that I had created from submillimetric datasets (0.7mm isometric) and so the freesurfer volumes (e.g. mri/orig.mgz and mri/aseg.nii.gz) are larger than those expected by create_roi in maskcreation.py. The latter expects a 256x256x256 volume, but mine are 293x293x293.

create_roi creates an empty volume (variable "rois", filled with zeros) that is 256x256x256 voxels (lines 232, see also line 222), then uses mri_label2vol to convert the label file to a volume that has the same dimensions as orig.mgz (293x293x293 in my case), and finally uses the converted label volume to assign the label number in empty volume "rois". If any point of the exported label is beyond the 256th voxel in any of the 3 dimensions, then the function fails because it tries to access a datapoint in the "rois" volume that doesn't exist. I must have got lucky with the one subject where it works (presumably all labels are within 256 voxels of the origin in this particular case).

The solution is to create the "rois" volume with the same dimensions as mri/orig.mgz (which are presumably the same as aseg.mgz), instead of 256x256x256

I've made the change, but I still need to figure out how to run the modified code, as I'm not used to programming in Python.