Commit 5c6ebdd8 authored by Arvid Lundervold's avatar Arvid Lundervold

ignore nilearn_cache

parent b6a0fd65
......@@ -37,3 +37,4 @@ Lab5-DCE-MRI/data
# Lab6
Lab6-Networks-Graphs/data
Lab6-Networks-Graphs/nilearn_cache
{"duration": 2.0306451320648193, "input_args": {"imgs": "'/Users/arvid/nilearn_data/development_fmri/development_fmri/sub-pixar123_task-pixar_space-MNI152NLin2009cAsym_desc-preproc_bold.nii.gz'", "extraction_function": "<nilearn.input_data.nifti_spheres_masker._ExtractionFunctor object at 0x7fa588534a60>", "parameters": "{'allow_overlap': False, 'detrend': True, 'dtype': None, 'high_pass': 0.01, 'high_variance_confounds': False, 'low_pass': 0.1, 'mask_img': None, 'radius': 8, 'seeds': [(0, -52, 18), (-46, -68, 32), (46, -68, 32), (1, 50, -5)], 'smoothing_fwhm': None, 'standardize': True, 'standardize_confounds': True, 't_r': 2}", "confounds": "['/Users/arvid/nilearn_data/development_fmri/development_fmri/sub-pixar123_task-pixar_desc-reducedConfounds_regressors.tsv']", "copy": "True", "dtype": "None"}}
\ No newline at end of file
# first line: 24
def filter_and_extract(imgs, extraction_function,
parameters,
memory_level=0, memory=Memory(location=None),
verbose=0,
confounds=None,
copy=True,
dtype=None):
"""Extract representative time series using given function.
Parameters
----------
imgs : 3D/4D Niimg-like object
Images to be masked. Can be 3-dimensional or 4-dimensional.
extraction_function : function
Function used to extract the time series from 4D data. This function
should take images as argument and returns a tuple containing a 2D
array with masked signals along with a auxiliary value used if
returning a second value is needed.
If any other parameter is needed, a functor or a partial
function must be provided.
For all other parameters refer to NiftiMasker documentation
Returns
-------
signals : 2D numpy array
Signals extracted using the extraction function. It is a scikit-learn
friendly 2D array with shape n_samples x n_features.
"""
# Since the calling class can be any *Nifti*Masker, we look for exact type
if verbose > 0:
class_name = enclosing_scope_name(stack_level=10)
# If we have a string (filename), we won't need to copy, as
# there will be no side effect
if isinstance(imgs, str):
copy = False
if verbose > 0:
print("[%s] Loading data from %s" % (
class_name,
_utils._repr_niimgs(imgs, shorten=False)))
imgs = _utils.check_niimg(imgs, atleast_4d=True, ensure_ndim=4,
dtype=dtype)
sample_mask = parameters.get('sample_mask')
if sample_mask is not None:
imgs = image.index_img(imgs, sample_mask)
target_shape = parameters.get('target_shape')
target_affine = parameters.get('target_affine')
if target_shape is not None or target_affine is not None:
if verbose > 0:
print("[%s] Resampling images" % class_name)
imgs = cache(
image.resample_img, memory, func_memory_level=2,
memory_level=memory_level, ignore=['copy'])(
imgs, interpolation="continuous",
target_shape=target_shape,
target_affine=target_affine,
copy=copy)
smoothing_fwhm = parameters.get('smoothing_fwhm')
if smoothing_fwhm is not None:
if verbose > 0:
print("[%s] Smoothing images" % class_name)
imgs = cache(
image.smooth_img, memory, func_memory_level=2,
memory_level=memory_level)(
imgs, parameters['smoothing_fwhm'])
if verbose > 0:
print("[%s] Extracting region signals" % class_name)
region_signals, aux = cache(extraction_function, memory,
func_memory_level=2,
memory_level=memory_level)(imgs)
# Temporal
# --------
# Detrending (optional)
# Filtering
# Confounds removing (from csv file or numpy array)
# Normalizing
if verbose > 0:
print("[%s] Cleaning extracted signals" % class_name)
sessions = parameters.get('sessions')
region_signals = cache(
signal.clean, memory=memory, func_memory_level=2,
memory_level=memory_level)(
region_signals,
detrend=parameters['detrend'],
standardize=parameters['standardize'],
standardize_confounds=parameters['standardize_confounds'],
t_r=parameters['t_r'],
low_pass=parameters['low_pass'],
high_pass=parameters['high_pass'],
confounds=confounds,
sessions=sessions)
return region_signals, aux
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment