[Neuroimaging] dipy target streamline filtering

Marc-Alexandre Côté marc.cote.19 at gmail.com
Wed Apr 11 20:56:54 EDT 2018


  Great! :-)


  2018-04-10 18:55 GMT-0400 Kevin R Sitek <ksitek at mit.edu>
> Thank you Marc! This worked for me.
>
> Kevin
>
>> On Apr 4, 2018, at 9:14 PM, Marc-Alexandre Côté 
>> <marc.cote.19 at gmail.com <mailto:marc.cote.19 at gmail.com>> wrote:
>>
>>  Hi Kevin,
>>
>> Can you try using the new Nibabel's streamlines API 
>> (https://github.com/nipy/nibabel/tree/master/nibabel/streamlines)? A 
>> convenient way to use it is through the dipy.io.streamlines module
>>
>> https://github.com/nipy/dipy/blob/master/dipy/io/streamline.py
>>
>> Let me know if you still have negative coordinates.
>>
>> --Marc
>>
>>
>>  2018-04-03 14:03 GMT-0400 Kevin R Sitek <ksitek at mit.edu>
>>>
>>> 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
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Neuroimaging mailing list
>>> Neuroimaging at python.org
>>> https://mail.python.org/mailman/listinfo/neuroimaging
>>
>

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


More information about the Neuroimaging mailing list