def transform_imgs(self, imgs_list, confounds=None, copy=True, n_jobs=1,
mmap_mode=None):
"""Prepare multi subject data in parallel
Parameters
----------
imgs_list: list of Niimg-like objects
See http://nilearn.github.io/manipulating_images/input_output.html.
List of imgs file to prepare. One item per subject.
confounds: list of confounds, optional
List of confounds (2D arrays or filenames pointing to CSV
files). Must be of same length than imgs_list.
copy: boolean, optional
If True, guarantees that output array has no memory in common with
input array.
n_jobs: integer, optional
The number of cpus to use to do the computation. -1 means
'all cpus'.
Returns
-------
region_signals: list of 2D numpy.ndarray
List of signal for each element per subject.
shape: list of (number of scans, number of elements)
"""
self._check_fitted()
raw = True
# Check whether all imgs from imgs_list are numpy instance, or fallback
# to MultiNiftiMasker (could handle hybrid imgs_list but we do not
# need it for the moment)
for imgs in imgs_list:
if isinstance(imgs, str):
name, ext = os.path.splitext(imgs)
if ext != '.npy':
raw = False
break
elif not isinstance(imgs, np.ndarray):
raw = False
break
if raw:
data = Parallel(n_jobs=n_jobs)(delayed(np.load)(imgs,
mmap_mode=mmap_mode)
for imgs in imgs_list)
return data
else:
return MultiNiftiMasker.transform_imgs(self, imgs_list,
confounds=confounds,
copy=copy,
n_jobs=n_jobs, )
评论列表
文章目录