-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Image based streamlines_registration: unable to warp streamlines into template" #2786
Comments
Hi @WilliamFCB, It has been solved but not documented. Unfortunately, we will have time to document and update this tutorial only after the workshop. But we can discuss about it and help during the workshop! Sorry for that |
Hi Serge, Unfortunately, I will not be able to attend the workshop this year. However, I would not need the whole documentation I would think. Maybe you could share the "new" line of code for applying the warp at the end? |
Normally, |
Hi Serge, Many thanks for your quick response Should anything be changed when saving the mni_streamlines to file? I now use, from the "old" tutorial: from dipy.io.stateful_tractogram import Space, StatefulTractogram sft = StatefulTractogram(mni_streamlines, fa_temp_img, Space.RASMM) save_tractogram(sft,'/mnt/scratch/VIA11/sub-via003ses01prisma/tractseg_output/MNI_CST_left6.tck', bbox_valid_check=False) However, I get the following error: bbox_valid_check=False) File "/tmp/ipykernel_951197/346544094.py", line 6, in <cell line: 6> File "/mrhome/wimb/anaconda3/envs/tractseg2.7/lib/python3.8/site-packages/dipy/io/streamline.py", line 67, in save_tractogram File "/mrhome/wimb/anaconda3/envs/tractseg2.7/lib/python3.8/site-packages/nibabel/streamlines/init.py", line 137, in save File "/mrhome/wimb/anaconda3/envs/tractseg2.7/lib/python3.8/site-packages/nibabel/streamlines/tck.py", line 226, in save File "/mrhome/wimb/anaconda3/envs/tractseg2.7/lib/python3.8/site-packages/numpy/lib/index_tricks.py", line 412, in getitem File "<array_function internals>", line 180, in concatenate ValueError: all the input arrays must have same number of dimensions, but the array at index 0 has 1 dimension(s) and the array at index 1 has 2 dimension(s) Any ideas about what might be amiss? Many thanks in advance! |
I can not look into it right now, but for sure,I will give a look a bit later this week |
I fully understand... Good luck with the workshop! Many thanks |
I assume something is missing to correctly structure mni_streamlines after using mapping.transform_points. Normally, the streamlines are organized as a list of size 10000 and organized in [Numpy array, Numpy array, .....] when using mni_streamlines = mapping.transform_points(sft.streamlines) So I clearly miss a an organizational operation I guess it has something to do with data_per_point, data_per_streamline |
Please be patient with me, I am a newbie .... What I am saying is that the resulting mni_streamlines are not organized correctly- Currently, it is just an array Looking at the API I assume the organization of has something to do with "data_per_point" and "data_per_streamline" |
No worries, This is a good catch ! I can see in the function transform_points that we do not return a Streamline Object, we just return the points. We should. This need an update. I recommend you to reuse/duplicate the input streamline and replace the data variable for now_. It should work |
Oke, thanks |
Reusing the input streamline would probably not be enough, I guess. How do I ensure including the right affine and non-linear warps to get the streamlines in MNI space? |
I tried Doesn't work ~ the streamlines are not in MNI space. The original streamlines seem actually to fit better. This is over my pay grade :-). I will wait for you to look into it The warps are fine. I warped the input FA to MNI, and it nicely fits the template |
Hi Serge, I did a bit more digging, and Ithink I figured it out. I have a lot of tracts I want to transfer to MNI (~50 per subject, ~370 subjects). I could do it the way below but would prefer a "valid"/"proper" DIPY implementation ( e.g., transform_point returning a streamline object and a proper dealing of the mapping.is_inverse). Any idea when this could be implemented realistically? coord2world=None from dipy.io.stateful_tractogram import Space, StatefulTractogram sft.streamlines._data=mni_streamlines save_tractogram(sft,'/mnt/scratch/VIA11/sub-via003ses01prisma/tractseg_output/MNI_CST_right.tck', bbox_valid_check=False) |
PS, on a more practical note. Again, many thanks in advance |
Thank you for feedback @WilliamFCB ! Happy that you solve your issue. Feel free to contribute and update the tutorial, it would be great and we will appreciate this contribution! Concerning the update of
we save them in a nifti file. We have a small function for that: |
also, more info on this thread: #2359 |
Many thanks! |
Hi Serge, |
Maybe by using a mask and just registering a part of the brain. |
Many thanks I call it a day and see if I can figure it out in the coming days |
Hi Serge, I don't get it to work. It is not clear to me dipy's 3d masks requirements. I could not find any info on this in teh documentation or forum. Of course, might have missed it fa_temp_mask_data,fa_temp_mask_affine, fa_temp_mask_img = load_nifti(fa_temp_mask, return_img=True) I then defined the masks using. Not sure if this is the right way to do it though I then do the following warping steps: I then try to apply the masks in the full affine: I get the following error: Cell In[129], line 4 File ~/anaconda3/envs/tractseg2.8/lib/python3.8/site-packages/dipy/align/imaffine.py:1177 in optimize File ~/anaconda3/envs/tractseg2.8/lib/python3.8/site-packages/dipy/utils/deprecator.py:408 in wrapper File ~/anaconda3/envs/tractseg2.8/lib/python3.8/site-packages/dipy/align/imaffine.py:410 in transform File ~/anaconda3/envs/tractseg2.8/lib/python3.8/site-packages/dipy/utils/deprecator.py:408 in wrapper File ~/anaconda3/envs/tractseg2.8/lib/python3.8/site-packages/dipy/align/imaffine.py:363 in _apply_transform File dipy/align/vector_fields.pyx:1657 in dipy.align.vector_fields.__pyx_fused_cpdef TypeError: No matching signature found Any ideas? |
Hi Serge, I am still interested in the latter. However, I think I have found a general solution for the warping of individual FA images into MNI standard space that accounts for data in which part of the cerebellum is missing. Seems to work nicely. Al least on the two test datasets I ran :-) Question, how to do I transform point/streamlines in case I only want to apply the affine of the warp? Thanks in advance |
Hi Serge, It's really great you finally had time to update the tutorial! Unfortunately, I will not be able to try it out due to too many commitments. BW |
No problem, Thank you for your valuable feedback @WilliamFCB and again apologize for the delay. |
No need to apologise. I know you guys are very busy :-) |
In light of the upcoming workshop, I was curious if the issue as reported and discussed in #2703 #2400 and #2369 has been resolved
Many thanks in advance!
The text was updated successfully, but these errors were encountered: