-
Notifications
You must be signed in to change notification settings - Fork 25
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
Converting Freesurfer segmentation to LayNii rim format required by LN2_LAYERS #78
Comments
Dear @SMScottLee , Thanks for your question. I would be happy to point you to a python script that converts Freesurfer's
NOTE: The script above assumes the user already converted from |
Hi ofgulban, Thanks for your suggestion and it seems to work well! But I still have questions about the following steps. After the conversion and using LN2_LAYERS to label different numbers of layers, how do I get the final layer fMRI profiles? Are the four steps in this page (https://layerfmri.com/2018/03/11/quick-layering/) I should do? If I use LN2_LAYERS to have e.g., 20 layers, do I need to do the first step, upscaling? Sorry that after going through some of the articles and videos, I still couldn't figure out the exact steps/pipeline for using LayNii. Could you please again point me to the right resource and direction? Thanks for your help. If you think some of my questions could be a new issue, I'm happy to create it. Best regards, |
Dear @SMScottLee , No worries, feel free to continue asking questions here. A few points:
Maybe you can elaborate further what you mean by "final layer fMRI profiles" (different people mean different things by this). Do you have an example figure in mind? I can give you more specific directions if you clarify which inputs you currently have and what type of output/figure you are envisioning to have. |
Thanks for the suggestions. I'll watch them. |
I see, thanks @SMScottLee , I will be back to you in a few days with an example python script. |
Hi @SMScottLee ,
Hope these pointers will be useful for you to clarify how to plot layer profiles. |
Hi @ofgulban , Thank you so much! All the materials are very helpful and I'm following through them. I currently have the equivol_metric file, contrast images generated from SPM, and an ROI defined by statistical result. But I get an error regarding index match when taking the voxels from the ROI mask in your script. Is it because my equivol_metric file is whole-brain but the mask is an ROI? How could I get an equivol_metric image with the size of ROI, like the example in your comments and tutorials? Many thanks, |
Hi @SMScottLee , I am guessing that probably ypu have your nifti images at different resolutions. Which is why indexing is giving you trouble (probably you are trying to do logical indexing based on e.g. 100x100x100 array applied to 256x256x256). I recommend you to carefully check your input data dimensions. You can use several programs to understand your input dimensions (niimath, fslinfo, fslhd, or custom script in python e.g. 'print(myArray.shape')). Could you check this and let me know of your input image dimensions? Then I could better recommend you how to proceed. |
Yes, you are right. The dimensions of my aseg_rim_metric_equidist file are 320x320x320, but contrast and ROI files are 157x189x156. |
Hi @ofgulban , The previous contrast and ROI files have been normalized to a template. But the unnormalized ones also have different dimensions (240x234x54), because of different FOVs and resolutions of structural and functional images. Do you have any recommendations for this? Thank you, |
Hi @SMScottLee , |
In such cases, it might be easier for me to give you a recommendation based on your images. So, you can consider sending me a few images that you want to reslice, and I might be able to return back to you with a more concrete set of instructions. |
Thank you! I attach my rim file (aseg_rim.nii.gz), equivol_metric file (aseg_rim_metric_equidist.nii.gz), scalar map (con_0002.nii.gz), and ROI mask (rFFA_FWE05.nii.gz). |
I've resliced the metric_equidist file (attached) into the same dimensions as scalar map and ROI. The script for scatter plotting now works but I'm not sure the result is right. One possibility is that the con_0002 image is the difference between the activity of two conditions (in a face image paradigm). But when I plot only for the activity of one condition, the results look similar (dots appear across all extents of value and depth). |
After having a look at your inputs, yes your ROI is too large. Specifically, I would take a conjunction between your ROI and the gray matter that you have segmented. All the dark spots at depth = 0 comes from outside of the gray matter voxels. For reference, this is how the plot looks using the files you have attached above and after gray matter masking: As an additional note, your statistical map that you have attached looks very very smooth. So I am not sure if the preprocessing or data acquisition details are suitable for doing laminar investigations. As an example data, it works perfectly fine though. |
I have made videos addressing 2 issues encountered in this conversation. Putting here for future reference:
|
Hi @ofgulban , Thanks for the explanations and the two videos. They are very helpful! Yes, the statistical map was smoothed with 8mm FWHM to define ROIs. I'm now using LN_LAYER_SMOOTH for smoothing the unsmoothed data within layers but getting message "There are 0 layers/masks to smooth within". Best, |
Hi Scott, The LN_LAYERS_MOOTH program smoothes signal from voxels that are in the same layer. Whether or not a voxel is within a given layer is a binary criteria. With additional weighting of geodesic difference. Thus, the input file should be the layer file (not the metric file). I would even recommend to using the file with the layer bins (output of LN2LAYER with -equalbins option). There might be a way to achieve layer smoothing with LN2_UVD filter, that uses the metric file. But I am not sure if this is generally doable. I suspect it 'only' work within local patches. Best, renzo |
Hi @ofgulban , Thanks! I've smoothed the layer file and would like to plot layer profile of the smoothed image. Best, |
Dear @SMScottLee , This error indicates that you have nans or infinities in your data. You need to trace where these values are coming from. As a workaround you can replace the nans and inf with another value (eg 0). Maybe read about numpy's isfinite function. In addition, note that this issue is related to common programming knowledge and not a direct LayNii issue. Therefore I advise you to read up on nans and infinities and ways of dealing with them or preventing them. |
Hi all,
I've went through some of your tutorial articles and videos, but still don't know how to get the rim.nii as an input file to
LN2_LAYERS
. I saw that you're planning to add an option inLN2_RIMIFY
to convert Freesurfer segmentation torim.nii
. But in the meantime, could you point me to the resources or tell me how to get therim.nii
after Freesurfer segmentation?Thanks very much,
Scott
The text was updated successfully, but these errors were encountered: