Command line#

patch-denoise minimally requires a path to a NIfTI file, but it can take advantage of reconstructed phase data and/or noise volumes.

main#

main [OPTIONS] INPUT-FILE [ARGS]

Patch denoising CLI tool.

Parameters:

INPUT-FILE, --input-file, -i

Required

OUTPUT-FILE, --output-file, -o

Output denoised NIfTI file (4D). Default is D<input_file>.

--method, -m

Denoising method. [Choices: mp-pca, hybrid-pca, raw, optimal-fro, optimal-fro-noise, optimal-nuc, optimal-ope, nordic, adaptive-qut, Default: optimal-fro]

--patch-shape, -ps

Patch shape. Dimension separated by “,”. Use -1 to use the entire dimension. Example: 11,11,11,-1. [Default: (11, 11, 11, -1)]

--patch-overlap, -po

Patch overlap. Dimension separated by “,”. Use -1 to use the entire dimension. Example: 11,11,11,-1. [Default: (5, 5, 5, -1)]

--recombination, -r

Recombination method. [Choices: weighted, mean, average, center, Default: weighted]

--mask, -k

Mask NIfTI file (3D). if None, mask is computed automatically.

--mask-threshold, -t

Min % of overlap between a patch and the mask to trigger computation. [Default: 50]

--extras, -e

Extra parameters for the denoiser as -e.key=value

--nan-to-num, -n

Replace any NaN in input-data with VALUE

--verbose, -v

Repeat for increase verbosity (-vvv) [Default: 0]

--gpu, --cpu

Use GPU or CPU for computation. Requires patch_denoise.gpu module. GPU is enabled by default if available [Default: False]

--gpu-batch-size

Number of patches processed per GPU batch. If 0, measure the fastest size for this GPU/method/patch-shape once and cache it (~/.cache/patch_denoise/gpu_batch_size.json) for future runs. Ignored on CPU. [Default: 0]

--outmap.weights

Save the patch weights. [Default: False]

--outmap.noise-std

Save the noise standard deviation estimate. [Default: False]

--outmap.rank

Save the rank estimate. [Default: False]

--outmap.count

Save the patch count. [Default: False]

--input-phase, -ip

Input phase NIfTI file (4D). If provided, process complex data.

--noise-std-map, -N

Input Noise std map

--noise-std-map-phase

Input Noise std map, phase component.

Using patch-denoise on BIDS data#

Warning

These examples assume that the phase data are in radians. If they are in arbitrary units, you will need to rescale them before running patch-denoise.

Magnitude only#

patch-denoise \
    sub-01/func/sub-01_task-rest_part-mag_bold.nii.gz \
    sub-01_task-rest_part-mag_desc-denoised_bold.nii.gz \
    --method optimal-fro \
    --patch-shape 11 \
    --patch-overlap 5 \
    --recombination weighted \
    --mask-threshold 1

Magnitude with noise volumes#

patch-denoise \
    sub-01/func/sub-01_task-rest_part-mag_bold.nii.gz \
    sub-01_task-rest_part-mag_desc-denoised_bold.nii.gz \
    --noise-std-map sub-01/func/sub-01_task-rest_part-mag_noRF.nii.gz \
    --method optimal-fro \
    --patch-shape 11 \
    --patch-overlap 5 \
    --recombination weighted \
    --mask-threshold 1

Magnitude and phase#

patch-denoise \
    sub-01/func/sub-01_task-rest_part-mag_bold.nii.gz \
    sub-01_task-rest_part-mag_desc-denoised_bold.nii.gz \
    --input-phase sub-01/func/sub-01_task-rest_part-phase_bold.nii.gz \
    --method optimal-fro \
    --patch-shape 11 \
    --patch-overlap 5 \
    --recombination weighted \
    --mask-threshold 1

Magnitude and phase with noise volumes#

patch-denoise \
    sub-01/func/sub-01_task-rest_part-mag_bold.nii.gz \
    sub-01_task-rest_part-mag_desc-denoised_bold.nii.gz \
    --input-phase sub-01/func/sub-01_task-rest_part-phase_bold.nii.gz \
    --noise-std-map sub-01/func/sub-01_task-rest_part-mag_noRF.nii.gz \
    --noise-std-map-phase sub-01/func/sub-01_task-rest_part-phase_noRF.nii.gz \
    --method optimal-fro \
    --patch-shape 11 \
    --patch-overlap 5 \
    --recombination weighted \
    --mask-threshold 1