[Neuroimaging] dipy target streamline filtering

Kevin R Sitek ksitek at mit.edu
Tue Apr 3 14:03:01 EDT 2018


Hello,

I’m generating whole-sample streamlines with dipy’s CSD model. I’d like to also filter streamlines by region of interest, but running dipy.tracking.utils.target I’m getting
IndexError: streamline has points that map to negative voxel indices in the helper function _to_voxel_coordinates

[I originally posted this issue on neurostars: https://neurostars.org/t/filtering-streamlines-with-dipy-target/1493]

Since I’m using the same affine as the DWI data the streamlines were generated from, and since the target mask looks fine relative to the diffusion image, I’m wondering how the negative voxel indices could arise.

I am running target like this:

    from dipy.tracking.utils import target

    # read in streamlines
    from nibabel import trackvis as tv
    streams_in_orig, hdr = tv.read(streamlines)
    streams_in = list(streams_in_orig)

    # streams_in is [[array, None, None], ...]
    streams = []
    for s in streams_in:
        streams.append(s[0])

    target_mask_bool = np.array(target_mask.get_data(), dtype=bool, copy=True)

    target_sl_generator = target(streams, target_mask_bool, affine, include=True)
    target_streamlines = list(target_sl_generator)


where the streamlines .trk file had been generated as below:

eu = EuDX(peaks.gfa, peaks.peak_indices[..., 0],
                  odf_vertices = sphere.vertices,
                  seeds=10**6,
                  ang_thr=45)
streamlines = ((sl, None, None) for sl in eu)

hdr = nib.trackvis.empty_header()
hdr['voxel_size'] = fa_img.get_header().get_zooms()[:3]
hdr['voxel_order'] = 'LAS'
hdr['dim'] = FA.shape[:3]

sl_fname = os.path.abspath('streamline.trk')
nib.trackvis.write(sl_fname, streamlines, hdr, points_space='voxel')


I have the same issue when hdr['voxel_order'] = 'RAS' and when points_space=None.

Any pointers would be appreciated!

Kevin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/neuroimaging/attachments/20180403/e59c0d3f/attachment.html>


More information about the Neuroimaging mailing list