datman.metrics module

Classes and functions for generating QC metrics.

class datman.metrics.ABCDPHAMetrics(input_nii, output_dir)[source]

Bases: datman.metrics.Metric

generate()[source]
outputs = {'qc-abcd-fmri': {}}
class datman.metrics.AnatMetrics(input_nii, output_dir)[source]

Bases: datman.metrics.Metric

generate(img_gap=5, width=1600)[source]
outputs = {'images': {'.png': QCOutput(order=1, title=None, caption=None)}}
class datman.metrics.AnatPHAMetrics(input_nii, output_dir)[source]

Bases: datman.metrics.Metric

generate()[source]
outputs = {'qc-adni': {'_stats.csv': None}}
class datman.metrics.DTIMetrics(nii_input, output_dir, bval=None, bvec=None)[source]

Bases: datman.metrics.MetricDTI

generate(img_gap=2, width=1600)[source]
outputs = {'images': {'_b0.png': QCOutput(order=2, title='b0 Montage', caption=None)}, 'montage': {'_montage.png': QCOutput(order=1, title=None, caption=None)}, 'qc-dti': {'_directions.png': QCOutput(order=3, title='bvec Directions', caption=None), '_qascripts_dti.csv': None, '_stats.csv': None}, 'qc-spikecount': {'_spikecount.csv': None}}
class datman.metrics.DTIPHAMetrics(nii_input, output_dir, bval=None, bvec=None)[source]

Bases: datman.metrics.MetricDTI

generate()[source]
outputs = {'qc-fbirn-dti': {}}
class datman.metrics.FMRIMetrics(input_nii, output_dir)[source]

Bases: datman.metrics.Metric

generate(img_gap=2, width=1600)[source]
outputs = {'images': {'_corr.png': QCOutput(order=4, title='Correlation Map', caption=None), '_raw.png': QCOutput(order=2, title='BOLD Montage', caption=None), '_sfnr.png': QCOutput(order=3, title='SFNR Map', caption=None)}, 'montage': {'_montage.png': QCOutput(order=1, title=None, caption=None)}, 'qc-fmri': {'_corr.nii.gz': None, '_fd.csv': None, '_qascripts_bold.csv': None, '_sfnr.nii.gz': None, '_spectra.csv': None, '_stats.csv': None}, 'qc-scanlength': {'_scanlengths.csv': None}}
class datman.metrics.FMRIPHAMetrics(input_nii, output_dir)[source]

Bases: datman.metrics.Metric

generate()[source]
outputs = {'qc-fbirn-fmri': {'_images.jpg': QCOutput(order=1, title=None, caption=None), '_plots.jpg': QCOutput(order=2, title=None, caption=None), '_stats.csv': None}}
class datman.metrics.IgnoreMetrics(input_nii, output_dir)[source]

Bases: datman.metrics.Metric

exists()[source]
generate()[source]
outputs = {}
write_manifest(overwrite=False)[source]
class datman.metrics.Metric(input_nii, output_dir)[source]

Bases: abc.ABC

command_succeeded(command_name)[source]
exists()[source]
abstract generate()[source]
classmethod get_requirements()[source]
classmethod is_runnable()[source]
make_image(output, img_gap=2, width=1600, nii_input=None)[source]

Uses FSL’s slicer function to generate a png from a nifti file.

Parameters
  • output (str) – The full path to write the output image to

  • img_gap (int, optional) – Size of the “gap” to insert between slices. Defaults to 2.

  • width (int, optional) – width (in pixels) of output image. Defaults to 1600.

  • nii_input (str, optional) – The nifti image to visualize. If not given, self.input will be used.

make_manifest()[source]
make_montage(output)[source]

Uses FSL’s slicer function to generate a montage of three slices.

Parameters

output (str) – The full path to write the result to.

property manifest_path
abstract outputs()[source]
read_manifest()[source]
requires = {'images': ['slicer'], 'montage': ['slicer', 'pngappend']}
run(command, output)[source]

Run a command if outputs are still needed.

Parameters
  • command (str) – The exact string command to run.

  • output (str) – A command name (as defined in self.commands) or a full path to a single file.

Raises

QCException – If any expected outputs haven’t been generated.

set_outputs()[source]
write_manifest(overwrite=False)[source]
class datman.metrics.MetricDTI(nii_input, output_dir, bval=None, bvec=None)[source]

Bases: datman.metrics.Metric

class datman.metrics.QAPHAMetrics(nii_input, output_dir, bval=None, bvec=None)[source]

Bases: datman.metrics.MetricDTI

generate()[source]
outputs = {'qa-dti': {'B0Distortion-PAR.jpg': QCOutput(order=1, title=None, caption=None), 'CentralSlice-PAR.jpg': QCOutput(order=2, title=None, caption=None), 'DiffImgs-PAR.jpg': QCOutput(order=3, title=None, caption=None), 'DiffMasks-PAR.jpg': QCOutput(order=4, title=None, caption=None), 'MaskCentralSlice-PAR.jpg': QCOutput(order=5, title=None, caption=None), 'NyquistRatio-PAR.jpg': QCOutput(order=6, title=None, caption=None), 'Plot-EddyCurrentDist-PAR.jpg': QCOutput(order=7, title=None, caption=None), 'SNRImgs-PAR.jpg': QCOutput(order=8, title=None, caption=None), 'Section2.3.1_SNR_ADC.csv': None, 'Section2.3.2_B0DistortionRatio.csv': None, 'Section2.3.3_EddyCurrentDistortions.csv': None, 'Section2.3.4_AveNyqRatio.csv': None, 'Section2.3.5_FAvalues.csv': None, 'StdPlotsHist-PAR.jpg': QCOutput(order=9, title=None, caption=None)}}
update_expected_outputs()[source]
class datman.metrics.QCOutput(order: int = - 1, title: str = None, caption: str = None)[source]

Bases: object

caption: str = None
order: int = -1
title: str = None
datman.metrics.get_handlers(subject)[source]

Returns the set of QC functions to use for a subject.

Parameters

subject (datman.scan.Scan) – The session that metrics must be generated for.

Returns

A dictionary of string QC ‘types’ mapped to the function

used to generate QC metrics for it.

Return type

dict