nipy / nibabel

Python package to access a cacophony of neuro-imaging file formats
http://nipy.org/nibabel/
Other
634 stars 258 forks source link

Trying to access dlabel.nii dynamic field #1308

Open sara-silvaad opened 3 months ago

sara-silvaad commented 3 months ago

Hello! I think this may be a bit of a reach but I am having an issue with the {subject}.aparc.32k_fs_LR.dlabel.nii files from HCP, I've looked all over the internet and found nothing. To extract the ROI mapping, this is essentially what I've done:

def load_atlas_aux(path2atlas):

try:
    cifti_file = nib.load(path2atlas)
except Exception as e:
    print("Error loading CIFTI file:", e)
    return None

data = cifti_file.get_fdata()
segmentation_atlas = data.ravel()

return segmentation_atlas

It works well, but it does not provide the same resaults I obtained from my matlab base file, which does something different by accessing a particular mapping like this:

subjlab = ft_read_cifti(path2atlas); load_atlas_cmd = strcat('subjlab.x',subject,'_aparc'); segmentation_atlas = eval(load_atlas_cmd);

The problem is that cifti in matlab obviously doesn't have the same implementation as nibabel library so I don't know how to access that specific "attribute" of the atlas with this library. Maybe someone has faced something similar before or has any guidance for me, thank you!!

effigies commented 3 months ago

It's unclear to me what you're trying to do. What do you get out of your MATLAB code? Do you have an example file where you can show the differences in Python and MATLAB?