Index out of bound during Tractometry
See original GitHub issueI am getting an error when running tractometry that reads:
UserWarning: Thedipy.stats module is still under heavy development and functionality, as well as the API is likely to change in future versions of the software
warnings.warn(w_string)
0%| | 0/50 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/usr/local/bin/Tractometry", line 138, in <module> main()
File "/usr/local/bin/Tractometry", line 109, in main
predicted_peaks=predicted_peaks, affine=scalar_image.affine)
File "/usr/local/lib/python3.5/dist-packages/tractseg/libs/tractometry.py", line 64, in evaluate_along_streamlines
streamlines = _orient_to_same_start_region(streamlines, beginnings)
File "/usr/local/lib/python3.5/dist-packages/tractseg/libs/tractometry.py", line 42, in _orient_to_same_start_region
if beginnings[int(startpoint[0]), int(startpoint[1]), int(startpoint[2])] == 0:
IndexError: index 178 is out of bounds for axis 1 with size 174
Steps taken to replicate on TractSeg 2.1.1: 0) Preprocessed dwi (Diffusion.nii.gz, single shell acquisition, has undergone denoising, eddy, and N4 bias correction), along with the b0 mask (nodif_brain_mask.nii.gz) and FA map (FA.nii.gz) are copied to the working directory.
-
Create peaks from preprocessed data (not rigidly aligned to MNI, but in the same orientation)
TractSeg -i Diffusion.nii.gz -o tractseg_output --raw_diffusion_input --brain_mask nodif_brain_mask.nii.gz --output_type tract_segmentation -
Remove the recently created bundle segmentations because I have to flip the peaks over X axis (discovered this primarily through trial-and-error). Is there a wrapper function in TractSeg just to produce the MrTrix peaks so I can avoid creating the bundles twice?
rm -r tractseg_output/bundle_segmentations -
Flip peaks and recreate bundle segmentations
flip_peaks -i tractseg_output/peaks.nii.gz -o tractseg_output/peaks_flip_x.nii.gz -a xTractSeg -i tractseg_output/peaks_flip_x.nii.gz -o tractseg_output --output_type tract_segmentationThe peaks and bundle segmentations look correct after this step (can provide images if needed) -
Create Ending Segmentation, TOM, and TOM trackings
TractSeg -i tractseg_output/peaks_flip_x.nii.gz -o tractseg_output --output_type endings_segmentationTractSeg -i tractseg_output/peaks_flip_x.nii.gz -o tractseg_output --output_type TOMTracking -i tractseg_output/peaks_flip_x.nii.gz -o tractseg_output --tracking_format trk(should I specify --nr_fibers here?)
There are no errors up until this point, and the .trk fibers look great!
- Attempt tractometry
Tractometry -i TOM_trackings/ -o FA.csv -e endings_segmentations/ -s FA.nii.gz
This is where the error occurs. If it’s of any help, I am using the Brainlife singularity container . Please let me know if anymore information would be helpful.
Thanks, Steven
Issue Analytics
- State:
- Created 3 years ago
- Comments:5

Top Related StackOverflow Question
Looking through the documentation of Tractometry, I did not know that there was a --tracking_format argument for that as well. I changed it to trk to match the format of Tracking, and now it seems to work.
The following outputs from the fslhd command show the sform and qform affine matrices. While the offset did not seem to be in those matrices, there was an image_offset output which was constantly 352.
FA.nii.gz
peaks_flip_x.nii.gz
bundle_segmentations/CST_right.nii.gz
endings_segmentations/CST_right_b.nii.gz
TOM/CST_right.nii.gz