Skip to content
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

Make the resampled parcellation in parcellate.Parcellater outside-accessible #143

Open
1 task done
LeonDLotter opened this issue Jan 26, 2024 · 0 comments
Open
1 task done

Comments

@LeonDLotter
Copy link

Description of issue

Hi folks,

I was wondering if you could make a small change to the neuromaps.parcellate.Parcellater class to make the resampled parcellation (if resampling_target = data) accessible from outside of the class?

Example:

# initiate the class with some volumetric parcellation with 1mm voxelsize: "parc_1mm"
parcellater = neuromaps.parcellate.Parcellater(
    parcellation=parc_1mm, 
    space="MNI152",
    resampling_target="data"
).fit()

# apply to a file with 3mm voxelsize: "file_3mm"
parcellated_data = parcellater.transform(
    data=file_3mm,
    space="MNI152"
)

# internally, this will resample the parcellation to 3mm voxelsize (line 155), 
# but the resampled parcellation remains a local variable. 
# I would like to access it, e.g. as an instance variable
parc_3mm = parcellater._parc 

I obviously can work around by doing the resampling before calling Parcellater or by modifying your code directly. But I would like to incorporate your methods in a tool of my own and it would be more elegant that way. :)

Specifically, I want to access the resampled parcellation to identify parcels that became too small after resampling or dont contain any data. This can lead to cases in which the nilearn masker that you use internally just drops parcels from the output. To then map the output to the parcel indices and fill in the dropped parcels with nan values, I have to check which parcel indices are actually missing in the resampled parcellation (i.e., comparing np.unique(parc_1mm.get_fdata()) with np.unique(parc_3mm.get_fdata()). I hope that was understandable :D .

Thanks a lot!
Best wishes, Leon

Code of Conduct

  • I agree to follow the neuromaps Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant