Nilearn: searchlight with leave one run out cross-validation

Dear all

I’m trying to run a searchlight analysis using leave-one-run-out (LORO-CV) cross-validation. In nilearn, LORO-CV can be achieved using cv = LeaveOneGroupOut() and then setting the groups parameter (groups=runs).
However, the function:
“searchlight = nilearn.decoding.SearchLight(
mask_filename,
radius=10, n_jobs=n_jobs,
verbose=1, cv=cv)
searchlight.fit(fmri_img, y)”
does not allow a groups parameter. How can I implement LORO-CV here ? I did not find any hints in the tutorials…

thanks for help!
mike

Ahoi hoi @Mike_Myers,

I’m not entirely sure where and how you tried to include the groups parameter. However, given the information you included, something like the following should work:

cv = LeaveOneGroupOut()

runs = array_indicating_run_number_of_volumes

searchlight = nilearn.decoding.SearchLight(
mask_filename,
radius=10, n_jobs=n_jobs,
verbose=1, cv=cv)

searchlight.fit(image_data, labels, groups=runs)

Please note, that the groups parameter should be set during .fit().

HTH, cheers, Peer

1 Like

hoihoi :slight_smile: and thanks Peer!