mia_processes.bricks.reports package

The bricks and functions to calculate the values needed in the reports and to create the report itself.

Submodules

mia_processes.bricks.reports.processes module

The report preprocess library of the mia_processes package.

The purpose of this module is to provide bricks and functions to compute necessary values for reporting.

Contains:
Class:
  • AnatIQMs

  • BoldIQMs

  • BoldIQMsPlot

  • CarpetParcellation

  • ComputeDVARS

  • FramewiseDisplacement

  • LateralizationIndexCurve

  • Mean_stdDev_calc

  • PlotSignalROI

  • Result_collector

  • Spikes

Function:
  • art_qi1

  • art_qi2

  • cjv

  • cnr

  • efc

  • fber

  • fuzzy_jaccard

  • find_peaks

  • find_spikes

  • gsr

  • image_binary_dilation

  • normalize_mc_params

  • regress_poly

  • rpve

  • snr

  • snr_dietrich

  • summary_stats

  • volume_fraction

  • wm2max

  • _AR_est_YW

  • _flatten_dict

  • _prepare_mask

  • _robust_zscore

class mia_processes.bricks.reports.processes.AnatIQMs[source]

Bases: ProcessMIA

Computes the anatomical IQMs

Please, see the complete documentation for the AnatIQMs brick in the mia_processes website

adapted from mriqc

Note

  • Type ‘AnatIQMs.help()’ for a full description of this process parameters.

  • Type ‘<AnatIQMs>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<AnatIQMs>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.BoldIQMs[source]

Bases: ProcessMIA

Computes the functional IQMs

Please, see the complete documentation for the BoldIQMs brick in the mia_processes website

adapted from mriqc

Note

  • Type ‘BoldIQMs.help()’ for a full description of this process parameters.

  • Type ‘<BoldIQMs>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<BoldIQMs>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.BoldIQMsPlot[source]

Bases: ProcessMIA

Plot a figure showing the slice-wise signal intensity at the extremes for the identification of spikes, the outliers metric, the DVARS, the FD and the carpetplot.

Note

  • Type ‘BoldIQMsPlot.help()’ for a full description of this process parameters.

  • Type ‘<BoldIQMsPlot>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<BoldIQMsPlot>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation/instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. In order not to include an output in the database, this output must be a value of the optional key ‘notInDb’ of the self.outputs dictionary. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.CarpetParcellation[source]

Bases: ProcessMIA

Dilate the brain mask, remove it from itself then generate the union of the obtained crown mask and the EPI parcellation

Please, see the complete documentation for the CarpetParcellation brick in the mia_processes website

Adapted from niworkflows binary dilatation, niworkflows binary subtraction, mriqc

Note

  • Type ‘CarpetParcellation.help()’ for a full description of this process parameters.

  • Type ‘<CarpetParcellation>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<CarpetParcellation>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation/instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. In order not to include an output in the database, this output must be a value of the optional key ‘notInDb’ of the self.outputs dictionary. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.ComputeDVARS[source]

Bases: ProcessMIA

Computes the DVARS

Please, see the complete documentation for the ComputeDVARS brick in the mia_processes website

adapted from nipype

Note

  • Type ‘ComputeDVARS.help()’ for a full description of this process parameters.

  • Type ‘<ComputeDVARS>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<ComputeDVARS>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation/instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. In order not to include an output in the database, this output must be a value of the optional key ‘notInDb’ of the self.outputs dictionary. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.FramewiseDisplacement[source]

Bases: ProcessMIA

Calculate the FD (framewise displacement) as in [Power2012]

This implementation reproduces the calculation in fsl_motion_outliers

[Power2012] Power et al., Spurious but systematic correlations in functional connectivity MRI networks arise from subject motion, NeuroImage 59(3).

Please, see the complete documentation for the FramewiseDisplacement brick in the mia_processes website

adapted from nipype

Note

  • Type ‘FramewiseDisplacement.help()’ for a full description of this process parameters.

  • Type ‘<FramewiseDisplacement>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<FramewiseDisplacement>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation/instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. In order not to include an output in the database, this output must be a value of the optional key ‘notInDb’ of the self.outputs dictionary. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.LateralizationIndexCurve[source]

Bases: ProcessMIA

Compute iteratively the lateralization of activation in functional MRI data.

It is a python adaptation of the part ‘Iterative (LI-curves)’ of the SPM LI-toolbox (Matlab)

If you are using this brick please cite: - Wilke M & Lidzba K: LI-tool: A new toolbox to assess lateralization in functional MR-data, J Neurosci Meth, 2007, 163: 128-136

Please, see the complete documentation for the LateralizationIndexCurve brick in the mia_processes website

Note

  • Type ‘LateralizationIndexCurve.help()’ for a full description of this process parameters.

  • Type ‘<LateralizationIndexCurve>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<LateralizationIndexCurve>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.Mean_stdDev_calc[source]

Bases: ProcessMIA

Makes the mean and standard deviation of parametric_maps

  • The rois_files parametric_maps are first resized, if necessary, to the size of the parametric_maps. Next, the parametric_maps and the rois_files are convolved. Finally, the mean and standard deviation are calculated for the corresponding ROIs.

  • The “PatientName_data/ROI_data/ROI_analysis” directory is created to receive the results. If this directory exists at runtime, it is overwritten.

  • To work correctly, the database entry for the first element of parametric_maps must have the PatientName tag filled in.

Please, see the complete documentation for the Mean_stdDev_calc brick in the mia_processes website

Note

  • Type ‘Mean_stdDev_calc.help()’ for a full description of this process parameters.

  • Type ‘<Mean_stdDev_calc>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<Mean_stdDev_calc>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation/instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. In order not to include an output in the database, this output must be a value of the optional key ‘notInDb’ of the self.outputs dictionary. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.PlotSignalROI[source]

Bases: ProcessMIA

Plot signals from ROI using a segmentation file with label

Please, see the complete documentation for the PlotSignalROI brick in the mia_processes website

Note

  • Type ‘PlotSignalROI.help()’ for a full description of this process parameters.

  • Type ‘<PlotSignalROI>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<PlotSignalROI>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.Result_collector[source]

Bases: ProcessMIA

Save a file.xlm with the data collection for a patient

  • To work correctly, the database entry for the first element of parameter_files must have the “PatientName” tag filled in.

  • The “PatientName_data/results_aggregation” directory is created to receive the results. If this directory exists at runtime, new results can overwrite old results with the same name.

  • To work correctly, the name of each file in parameter_files must be exactly like this:

    roi _ hemi _ calcul _ param _ contrast .txt, where:

    • roi: region of interest (ex. ACA)

    • hemi: hemisphere (ex. L)

    • calcul: type of calcul (ex. mean)

    • param: the parameter studied (ex. spmT)

    • contrast: the type of contrast/effect used (ex. BOLD)

Please, see the complete documentation for the Result_collector brick in the mia_processes website

Note

  • Type ‘Result_collector.help()’ for a full description of this process parameters.

  • Type ‘<Result_collector>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<Result_collector>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation/instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. In order not to include an output in the database, this output must be a value of the optional key ‘notInDb’ of the self.outputs dictionary. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.processes.Spikes[source]

Bases: ProcessMIA

Computes the number of spikes

Please, see the complete documentation for the Spikes brick in the mia_processes website

adapted from mriqc spikes_mask function and mriqc Spikes class

Note

  • Type ‘Spikes.help()’ for a full description of this process parameters.

  • Type ‘<Spikes>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<Spikes>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation/instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. In order not to include an output in the database, this output must be a value of the optional key ‘notInDb’ of the self.outputs dictionary. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

mia_processes.bricks.reports.processes.art_qi1(airmask, artmask)[source]

Detect artifacts in the image using the method described in [Mortamet2009].

Calculates \(\text{QI}_1\), as the proportion of voxels with intensity corrupted by artifacts normalized by the number of voxels in the background:

\[\text{QI}_1 = \frac{1}{N} \sum\limits_{x\in X_\text{art}} 1\]

Lower values are better.

Parameters:
  • airmask (numpy.ndarray) – input air mask, without artifacts

  • artmask (numpy.ndarray) – input artifacts mask

mia_processes.bricks.reports.processes.art_qi2(img, airmask, min_voxels=1000, max_voxels=300000)[source]

Calculates \(\text{QI}_2\), based on the goodness-of-fit of a centered \(\chi^2\) distribution onto the intensity distribution of non-artifactual background (within the “hat” mask):

\[\chi^2_n = \frac{2}{(\sigma \sqrt{2})^{2n} \, (n - 1)!}x^{2n - 1}\, e^{-\frac{x}{2}}\]

where \(n\) is the number of coil elements.

Parameters:
  • img (numpy.ndarray) – input data

  • airmask (numpy.ndarray) – input air mask without artifacts

mia_processes.bricks.reports.processes.cjv(mu_wm, mu_gm, sigma_wm, sigma_gm)[source]

Calculate the CJV, a measure related to SNR and CNR that is presented as a proxy for the INU artifact [Ganzetti2016].

Lower is better.

\[\text{CJV} = \frac{\sigma_\text{WM} + \sigma_\text{GM}}{|\mu_\text{WM} - \mu_\text{GM}|}.\]
Parameters:
  • mu_wm (float) – mean of signal within white-matter mask.

  • mu_gm (float) – mean of signal within gray-matter mask.

  • sigma_wm (float) – standard deviation of signal within white-matter mask.

  • sigma_gm (float) – standard deviation of signal within gray-matter mask.

Returns:

the computed CJV

mia_processes.bricks.reports.processes.cnr(mu_wm, mu_gm, sigma_air)[source]

Calculate the CNR [Magnota2006].

Higher values are better.

\[\text{CNR} = \frac{|\mu_\text{GM} - \mu_\text{WM} |}{\sqrt{\sigma_B^2 + \sigma_\text{WM}^2 + \sigma_\text{GM}^2}}\]

where \(\sigma_B\) is the standard deviation of the noise distribution within the air (background) mask.

Parameters:
  • mu_wm (float) – mean of signal within white-matter mask.

  • mu_gm (float) – mean of signal within gray-matter mask.

  • sigma_air (float) – standard deviation of the air surrounding the head (“hat” mask).

Returns:

the computed CNR

mia_processes.bricks.reports.processes.efc(img, framemask=None)[source]

Calculate the EFC [Atkinson1997].

Uses the Shannon entropy of voxel intensities as an indication of ghosting and blurring induced by head motion. A range of low values is better, with EFC = 0 for all the energy concentrated in one pixel.

\[\text{E} = - \sum_{j=1}^N \frac{x_j}{x_\text{max}} \ln \left[\frac{x_j}{x_\text{max}}\right]\]

with \(x_\text{max} = \sqrt{\sum_{j=1}^N x^2_j}\).

The original equation is normalized by the maximum entropy, so that the EFC can be compared across images with different dimensions:

\[\text{EFC} = \left( \frac{N}{\sqrt{N}} \, \log{\sqrt{N}^{-1}} \right) \text{E}\]
Parameters:
  • img (numpy.ndarray) – input data

  • framemask (numpy.ndarray) – a mask of empty voxels inserted after a rotation of data

mia_processes.bricks.reports.processes.fber(img, headmask, rotmask=None)[source]

Calculate the FBER [Shehzad2015], defined as the mean energy of image values within the head relative to outside the head.

Higher values are better.

\[\text{FBER} = \frac{E[|F|^2]}{E[|B|^2]}\]
Parameters:
  • img (numpy.ndarray) – input data

  • headmask (numpy.ndarray) – a mask of the head (including skull, skin, etc.)

  • rotmask (numpy.ndarray) – a mask of empty voxels inserted after a rotation of data

mia_processes.bricks.reports.processes.find_peaks(data)[source]
Parameters:

data – a numpy ndarray

Returns:

a list

mia_processes.bricks.reports.processes.find_spikes(data, spike_thresh)[source]

blabla

mia_processes.bricks.reports.processes.fuzzy_jaccard(in_tpms, in_mni_tpms)[source]

blabla

mia_processes.bricks.reports.processes.gsr(epi_data, mask, direction='y', ref_file=None, out_file=None)[source]

Compute the GSR [Giannelli2010].

The procedure is as follows:
  1. Create a Nyquist ghost mask by circle-shifting the original mask by \(N/2\).

  2. Rotate by \(N/2\)

  3. Remove the intersection with the original mask

  4. Generate a non-ghost background

  5. Calculate the GSR

Warning

This should be used with EPI images for which the phase encoding direction is known.

Parameters:
  • epi_data (str) – path to epi file

  • mask (str) – path to brain mask

  • direction (str) – the direction of phase encoding (x, y, all)

Returns:

the computed gsr

mia_processes.bricks.reports.processes.image_binary_dilation(in_mask, radius=2)[source]

Dilate the input binary mask.

Parameters:
  • in_mask (numpy.ndarray) – a 3D binary array

  • radius (int) – the radius of the ball-shaped footprint for dilation of the mask (optional)

mia_processes.bricks.reports.processes.lateralization_index_iter_curves(in_file, mask, mask_right, mask_left, roi_name, out_png)[source]

Function to iteratively calculate lateralization indices. Partial python adaptation of the LI-toolbox (https://www.fil.ion.ucl.ac.uk/spm/ext/#LI) (LI_iter.m)

Parameters:
  • in_file (string that represents a path) – SPMT filepath

  • mask (string that represents a path) – main inclusive mask filepath

  • mask_left (string that represents a path) – mask left filepath

  • mask_right (string that represents a path) – mask right filepath

  • roi_name (string) – main inclusive mask name

  • out_png (string that represents a) – out path

mia_processes.bricks.reports.processes.normalize_mc_params(params, source)[source]

Normalize a single row of motion parameters to the SPM format.

SPM saves motion parameters as:
  • x Right-Left (mm)

  • y Anterior-Posterior (mm)

  • z Superior-Inferior (mm)

  • rx Pitch (rad)

  • ry Roll (rad)

  • rz Yaw (rad)

mia_processes.bricks.reports.processes.regress_poly(degree, data, remove_mean=True, axis=-1, failure_mode='error')[source]

Returns data with degree polynomial regressed out. :param bool remove_mean: whether or not demean data (i.e. degree 0), :param int axis: numpy array axes along which regression is performed

mia_processes.bricks.reports.processes.rpve(pvms, seg)[source]
  • Computes the rPVe
    of each tissue class.
\[\text{rPVE}^k = \frac{1}{N} \left[ \sum\limits_{p^k_i \in [0.5, P_{98}]} p^k_i + \sum\limits_{p^k_i \in [P_{2}, 0.5)} 1 - p^k_i \right]\]
mia_processes.bricks.reports.processes.snr(mu_fg, sigma_fg, n)[source]

Calculate the SNR.

The estimation may be provided with only one foreground region in which the noise is computed as follows:

\[\text{SNR} = \frac{\mu_F}{\sigma_F\sqrt{n/(n-1)}}\]
where:
  • \(\mu_F\) is the mean intensity of the foreground

  • \(\sigma_F\) is the standard deviation of the same region

Parameters:
  • mu_fg (float) – mean of foreground.

  • sigma_fg (float) – standard deviation of foreground.

  • n (int) – number of voxels in foreground mask.

Returns:

the computed SNR

mia_processes.bricks.reports.processes.snr_dietrich(mu_fg, mad_air=0.0, sigma_air=1.0)[source]

Calculate the SNR.

This must be an air mask around the head, and it should not contain artifacts. The computation is done following the eq. A.12 of [Dietrich2007], which includes a correction factor in the estimation of the standard deviation of air and its Rayleigh distribution:

\[\text{SNR} = \frac{\mu_F}{\sqrt{\frac{2}{4-\pi}}\,\sigma_\text{air}}.\]
Parameters:
  • mu_fg (float) – mean of foreground.

  • sigma_air (float) – standard deviation of the air surrounding the head (“hat” mask).

Returns:

the computed SNR for the foreground segmentation

mia_processes.bricks.reports.processes.summary_stats(img, pvms, airmask=None, erode=True)[source]

Estimates the mean, the standard deviation, the 95% and the 5% percentiles of each tissue distribution.

Warning

Sometimes (with datasets that have been partially processed), the air mask will be empty. In those cases, the background stats will be zero for the mean, median, percentiles and kurtosis, the sum of voxels in the other remaining labels for n, and finally the MAD and the \(\sigma\) will be calculated as:

\[\sigma_\text{BG} = \sqrt{\sum \sigma_\text{i}^2}\]
mia_processes.bricks.reports.processes.volume_fraction(pvms)[source]

Computes the ICV fractions corresponding to the (partial volume maps).

\[\text{ICV}^k = \frac{\sum_i p^k_i}{\sum\limits_{x \in X_\text{brain}} 1}\]
Parameters:

pvms (list) – list of numpy.ndarray of partial volume maps.

mia_processes.bricks.reports.processes.wm2max(img, mu_wm)[source]

Calculate the WM2MAX, defined as the maximum intensity found in the volume w.r.t. the mean value of the white matter tissue. Values close to 1.0 are better:

\[\text{WM2MAX} = \frac{\mu_\text{WM}}{P_{99.95}(X)}\]

mia_processes.bricks.reports.reporting module

The reporting library of the mia_processes package.

The purpose of this module is to provide the reporting bricks necessary to generate automatic report at the end of a pipeline calculation.

Contains:
Class:
  • ReportAnatMriqc

  • ReportCO2inhalCvr

  • ReportFuncMriqc

  • ReportGE2REC

  • ReportGroupMriqc

  • ReportPerfDsc

class mia_processes.bricks.reports.reporting.ReportAnatMriqc[source]

Bases: ProcessMIA

Generates the report for anatomical data in MRIQC pipeline

Please, see the complete documentation for the ReportAnatMriqc brick in the mia_processes website

Note

  • Type ‘ReportAnatMriqc.help()’ for a full description of this process parameters.

  • Type ‘<ReportAnatMriqc>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<ReportAnatMriqc>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.reporting.ReportCO2inhalCvr[source]

Bases: ProcessMIA

Generates report for CVR study by CO2 inhalation task

Please, see the complete documentation for the ReportCO2inhalCvr brick in the mia_processes website

Note

  • Type ‘ReportCO2inhalCvr.help()’ for a full description of this process parameters.

  • Type ‘<ReportCO2inhalCvr>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<ReportCO2inhalCvr>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.reporting.ReportFuncMriqc[source]

Bases: ProcessMIA

Generates the report for functional data in MRIQC pipeline

Please, see the complete documentation for the ReportFuncMriqc brick in the mia_processes website

Note

  • Type ‘ReportFuncMriqc.help()’ for a full description of this process parameters.

  • Type ‘<ReportFuncMriqc>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<ReportFuncMriqc>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.reporting.ReportGE2REC[source]

Bases: ProcessMIA

Report for GE2REC pipeline

Please, see the complete documentation for the ReportGE2REC brick in the mia_processes website

Note

  • Type ‘ReportGE2REC.help()’ for a full description of this process parameters.

  • Type ‘<ReportGE2REC>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<ReportGE2REC>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.reporting.ReportGroupMriqc[source]

Bases: ProcessMIA

Generates a group report for mriqc pipelines

Please, see the complete documentation for the ReportGroupMriqc brick in the mia_processes website

Note

  • Type ‘ReportGroupMriqc.help()’ for a full description of this process parameters.

  • Type ‘<ReportGroupMriqc>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<ReportGroupMriqc>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.

class mia_processes.bricks.reports.reporting.ReportPerfDsc[source]

Bases: ProcessMIA

Generates report for Perfusion study using DSC-MRI

Please, see the complete documentation for the ReportPerfDsc brick in the mia_processes website

Note

  • Type ‘ReportPerfDsc.help()’ for a full description of this process parameters.

  • Type ‘<ReportPerfDsc>.get_input_spec()’ for a full description of this process input trait types.

  • Type ‘<ReportPerfDsc>.get_output_spec()’ for a full description of this process output trait types.

__init__()[source]

Dedicated to the attributes initialisation / instantiation.

The input and output plugs are defined here. The special ‘self.requirement’ attribute (optional) is used to define the third-party products necessary for the running of the brick.

list_outputs(is_plugged=None, iteration=False)[source]

Dedicated to the initialisation step of the brick.

The main objective of this method is to produce the outputs of the bricks (self.outputs) and the associated tags (self.inheritance_dic), if defined here. To work properly this method must return self.make_initResult() object.

Parameters:
  • is_plugged – the state, linked or not, of the plugs.

  • iteration – the state, iterative or not, of the process.

Returns:

a dictionary with requirement, outputs and inheritance_dict.

run_process_mia()[source]

Dedicated to the process launch step of the brick.