Skip to content

Minimal changes to get_searchlight_RDMs to make it more convenient #329

@mathias-sm

Description

@mathias-sm

get_searchlight_RDMs is very convenient when working with fMRI datasets, but a few small changes would make it easier for me to use, and might benefit others. As things stand, I basically wrote my own version of it, which is almost 100% identical to upstream. I am aware of the efforts in PR #253 whence this issue instead of a PR with my small changes.

There are two things that I would happily add because I use/need them:

  • calc_rdm takes more arguments than get_searchlight_RDMs does, making the later less flexible than the former, e.g. I needed to pass a cv_descriptor when using crossnobis distance, but get_searchlight_RDMs cannot handle that. Same with noise, prior_lambda and prior_weight. Adding them to get_searchlight_RDMs could be useful, possibly with **kwargs?
  • Parallelizing over chunks seems easy and reasonable, esp. as the searchlight util functions already make use of joblib's parallel. I did it by turning for chunks in tqdm(chunked_center, desc='Calculating RDMs...'): into a function like def chunk_to_rdm(chunk):, then called with RDM_corrs = Parallel(n_jobs=-1)(delayed(chunk_to_rdm)(chunk) for chunk in track(chunked_center)) followed by
for chunks, RDM_corr in zip(chunked_center, RDM_corrs):
    RDM[chunks, :] = RDM_corr.dissimilarities

I'd be happy to add these two changes (I have already added them locally to what I'm running, but this makes sharing my code with others harder), and would happily upstream them if it's considered useful.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions