TypeError for fit_transform

Hi everyone,

I was using NiftiMasker from Nilearn package. However, when running the following code:
epi_masker.fit_transform (f, confounds=dm_trim) with f being the path to the fMRI file, and dm_trim being the data frame with confounds, I always got an error stating: "TypeError: expected string or bytes-like object".

Moreover, this error only appears when I am using v0.9.1 of Nilearn, and the code runs fine when I am using v0.8.1. I have tried to import from nilearn.maskers or nilearn.input_data for 0.9.1, but it didn’t lead to any change. I have also tried to change f into a nibabel object instead of the path, yet still got the same error.

Any thoughts on why this is happening, or whether this is just a problem on my end would be really helpful!!

Thanks!

Amber.

P.S. This is the code for my epi_masker:

epi_masker= NiftiMasker(mask_img=mask_output,
high_pass=1/filtcutoff,
standardize=True,
t_r=tr,
memory=‘nilearn_cache’,
memory_level=1,
verbose=1)

Thx for posting.
Does the error dispear if you don’t specify the memory argument ?
Best,
Bertrand

It did! I am so surprised because the error message didn’t mention the memory argument at all. I would have no idea that was causing the error. Thank you so much!!

Well, it’s a nasty bug, that I don’t understand yet. Sorry !
Bertrand

1 Like