noahbenson / neuropythy

A neuroscience library for Python, intended to complement the existing nibabel library.
GNU Affero General Public License v3.0
115 stars 21 forks source link

Atlas function, error reading surfaces #25

Closed beyzakkoyunlu closed 2 years ago

beyzakkoyunlu commented 2 years ago

Hi,

I wanted to use atlas function with one of my subjects,, that is processed with FreeSurfer7 and using the following command "recon-all -all". When I use atlas func. I get relevant outputs but in FreeView or MATLAB I can't read them. Both give memory error and FreeView crashes.

I tried using sample function and processing bert also I tried using toolbox with docker, but every try gave same result. I don't get any error message, so I have no idea what might be the issue.

Secondly, I saw that your previous docker for applying ret. atlases has far more steps than the atlas function in this package, so I am wondering if I miss some steps in between...

Thank you in advance, Cheers, Beyza

noahbenson commented 2 years ago

Hi there! I really can't help you debug this without a lot more information:

Just based on what you've written, though, it sounds like maybe you are writing out curv files and trying to read them as image files.

beyzakkoyunlu commented 2 years ago

Hi,

Thank you! Yes, it appears I wasn't properly visualizing them :) I mean, I didn't think that I should "overlay" them, I thought that I can directly visualize them via load surface.

I will still explain, maybe someone in future can benefit from it.

I used python -m neuropythy atlas --verbose bert function

I tried to visualize them via FreeSurfer's "load surface" and in matlab "freesurfer_read_surf" functions, which didn't work... but now I understand that they were curv files, that's why.

I was referring to following docker https://hub.docker.com/r/nben/occipital_atlas , in this subject has to be registered to average surfaces, too. That was what I was referring to

noahbenson commented 2 years ago

Ahh, thanks! Glad you got it figured out!

For additional reference: the occipital_atlas docker is out-of-date and uses an older model, but the methods are all basically the same. The main difference is that the occipital_atlas used the fsaverage_sym surface instead of the lh and rh standard fsaverage surfaces, so you had to perform an additional surfreg step to get the subject surfaces registered to fsaverage_sym. The standard FreeSurfer pipline performs the standard lh/rh fsaverage surface registrations by default, and the new method uses models on these standard surfaces, so this step isn't usually needed in the new pipeline.

Also, just FYI, you can provide command-line options to have the data exported as an mgh or mgz file also (it is still just an overlay file in an MGH/MGZ file, but some tools prefer these formats or make it easier to read in MGH/MGZ). In Matlab, I think the function you want is read_curv() from the FreeSurfer / Matlab toolbox, or MRIread() for MGH/MGZ files.

beyzakkoyunlu commented 2 years ago

Ah I see the difference now... thanks for explanation

Thank you but after realizing what's the error I was able to create my label files and go further for my analysis :)

coopapap commented 2 years ago

Ah I see the difference now... thanks for explanation

Thank you but after realizing what's the error I was able to create my label files and go further for my analysis :)

Hi Beyza, I think I'm having the same issue. I can't visualize the surface files of the Benson 2014 atlas. Could you share how you figured it out?

beyzakkoyunlu commented 2 years ago

Ah I see the difference now... thanks for explanation Thank you but after realizing what's the error I was able to create my label files and go further for my analysis :)

Hi Beyza, I think I'm having the same issue. I can't visualize the surface files of the Benson 2014 atlas. Could you share how you figured it out?

Hi, you can view it by loading it as curvature over your surface in freeview, also you can use following command to convert it to labels and load as such

export roiname_array=(1 "V1v" "V1d" "V2v" "V2d" "V3v" "V3d" "hV4" "VO1" "VO2" "PHC1" "PHC2" \
    "TO2" "TO1" "LO2" "LO1" "V3B" "V3A" "IPS0" "IPS1" "IPS2" "IPS3" "IPS4" \
    "IPS5" "SPL1" "FEF")
export subjid=yourfubjectname

for i in {1..25}
do
 mri_cor2label --i ${SUBJECTS_DIR}/${subjid}/surf/rh.wang15_mplbl.mgz --id ${i} --l rh.wang15atlas.${roiname_array[${i}]}.label --surf ${subjid} rh inflated
done

I might have taken this from the author himself, if this is the case thanks again :)

coopapap commented 2 years ago

Amazing! Thanks Beyza :)

Do you have any idea how to do the same command for the left side of the cortex? Can it be done? I tried by just replacing "rh" within the command with "lh" but that didn't work!

Let me know if you were able to run the command for both left and right side :D