Oops, slight edit

import nibabel as nib

file_list = [os.path.join(os.getenv(‘SUBJECTS_DIR’), subject, ‘mri’, 
‘brainmask.mgz’)for subject in subject_list]
mri_list = [nib.load(fname) for fname in file_list]

On Feb 22, 2022, at 9:53 PM, Fischl, Bruce <bfis...@mgh.harvard.edu> wrote:


In python you should be able to do (assuming you have a  list of subject ids in 
subject_list):

import nibabel as nib

file_list = [os.path.join(os.getenv(‘SUBJECTS_DIR’), subject) for subject in 
subject_list]
mri_list = [nib.load(fname) for fname in file_list]

even for 1000 subjects it won’t take that long, depending of course on your 
disk speed. You shouldn’t have to convert from .mgz – nibabel can read it

From: freesurfer-boun...@nmr.mgh.harvard.edu 
<freesurfer-boun...@nmr.mgh.harvard.edu> On Behalf Of REEM ABU BAKR BAHATHIQ
Sent: Tuesday, February 22, 2022 9:28 PM
To: freesurfer@nmr.mgh.harvard.edu
Subject: [Freesurfer] convert .mgz to .nii


        External Email - Use Caution

Hello FreeSurfer experts,


I want to run a classification task using deep learning on data processed by 
Freesurfer recon-all and I have some queries. I will use brainmask .mgz

  First of all, based on my simple knowledge, I cannot feed my model with this 
output directly. .mgz files must be converted to a .nii file for use in 
analytics. I found that this is done by writing
mri_convert any_volume.mgz any_volume.nii.gz

But how can I convert the files of all participants (more than 1000) into .nii 
files instead of going one by one?

Are there any examples or tutorials provided to demonstrate the use of 
Freesurfer output in machine learning applications?

My greetings,
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

Reply via email to