Did I find the right examples for you? yes no

All Samples(1)  |  Call(0)  |  Derive(0)  |  Import(1)
Calculates z-score of timeseries removing timpoints with outliers.

Parameters
----------
image :
outliers :

Returns
-------
File : z-image

        def z_image(image,outliers):
    """Calculates z-score of timeseries removing timpoints with outliers.

    Parameters
    ----------
    image :
    outliers :

    Returns
    -------
    File : z-image
    """
    import numpy as np
    import nibabel as nib
    from nipype.utils.filemanip import split_filename
    import os
    if isinstance(image,list):
        image = image[0]
    if isinstance(outliers,list):
        outliers = outliers[0]
        
    def try_import(fname):
        try:
            a = np.genfromtxt(fname)
            return np.atleast_1d(a).astype(int)
        except:
            return np.array([]).astype(int)

    z_img = os.path.abspath('z_no_outliers_' + split_filename(image)[1] + '.nii.gz')
    arts = try_import(outliers)
    img = nib.load(image)
    data, aff = np.asarray(img.get_data()), img.get_affine()

    z_img2 = os.path.abspath('z_' + split_filename(image)[1] + '.nii.gz')
    z2 = (data - np.mean(data, axis=3)[:,:,:,None])/np.std(data,axis=3)[:,:,:,None]
    final_image = nib.Nifti1Image(z2, aff)
    final_image.to_filename(z_img2)

    if arts.size:
        data_mask = np.delete(data, arts, axis=3)
        z = (data_mask - np.mean(data_mask, axis=3)[:,:,:,None])/np.std(data_mask,axis=3)[:,:,:,None]
    else:
        z = z2
    final_image = nib.Nifti1Image(z, aff)
    final_image.to_filename(z_img)

    z_img = [z_img, z_img2]
    return z_img
        


src/b/r/BrainImagingPipelines-HEAD/bips/workflows/gablab/wips/scripts/base.py   BrainImagingPipelines(Download)
from utils import (create_compcorr, choose_susan, art_mean_workflow, z_image,
                   getmeanscale, highpass_operand, pickfirst, whiten)
from nipype.utils.filemanip import split_filename