Skip to main content

Skullduggery

skullduggery artwork

Skullduggery is a BIDS app for automated defacing of anatomical MRI images. It removes identifiable facial features from anatomical neuroimaging data while preserving brain tissue, protecting participant privacy in neuroimaging studies.

Features

  • Automated defacing - Uses template-based registration and hard-coded anatomical markers
  • Age-specific templates - Supports pediatric cohorts with age-based template selection from TemplateFlow
  • BIDS-compatible - Full integration with BIDS datasets and metadata
  • Multi-series support - Process multiple anatomical series in a single run
  • Quality assurance - Generates HTML reports with mosaic visualizations
  • DataLad integration - Optional support for git-annex metadata tracking
  • Flexible filtering - Select specific participants/sessions with BIDS filters

Installation

Basic Installation

pip install skullduggery

With DataLad Support

For optional git-annex metadata tracking:

pip install skullduggery[datalad]

Development Installation

pip install -e ".[test]"

Quick Start

Deface Your First Dataset

skullduggery /path/to/bids/dataset --participant-label 01 --report-dir ./reports

Process Multiple Participants

skullduggery /path/to/bids/dataset \
  --participant-label 01 02 03 \
  --save-all-masks \
  --report-dir ./defacing_reports

For Pediatric Data

skullduggery /path/to/bids/dataset \
  --template MNIInfant:cohort-06m09m \
  --report-dir ./pediatric_reports

Documentation

Complete command-line documentation is available in the Usage Guide and Examples.

  • Getting Started - Quick overview and your first command
  • Usage Guide - All command-line options explained
  • Command Reference - Quick lookup for flags and arguments
  • Examples - 12 real-world scenarios with complete commands

View the full documentation at: docs/ or online

Command-Line Options

Required Arguments

  • BIDS_PATH: Path to the BIDS dataset directory

Optional Arguments

  • --participant-label - Process specific participants (space-separated IDs, prefix 'sub-' optional)
  • --session-label - Process specific sessions (space-separated IDs, prefix 'ses-' optional)
  • --template - TemplateFlow template name (default: MNI152NLin6Asym)
  • --default-age VALUE:UNIT - Fallback age for participants missing age data (e.g., 5:years)
  • --save-all-masks - Save defacing masks for all series (default: only reference series)
  • --report-dir DIR - Directory for HTML reports and visualizations
  • --ref-bids-filters JSON - BIDS filters for selecting reference image (default: {"suffix": "T1w", "datatype": "anat"})
  • --other-bids-filters JSON - BIDS filters for images to deface (default: [{"datatype": "anat"}])
  • --datalad - Enable DataLad integration for metadata tracking
  • --deface-sensitive - Only deface images marked with distribution-restrictions metadata
  • --force-reindex - Force pyBIDS database reindexing
  • --debug LEVEL - Set logging level (default: info)

How It Works

The defacing pipeline follows these steps:

  1. Template Selection - Loads appropriate template from TemplateFlow (age-specific if available)
  2. Reference Registration - Registers participant's reference image to template space
  3. Mask Warping - Warps template-space defacing mask to participant's native space
  4. Series Defacing - Applies mask to all anatomical series for the participant
  5. Report Generation - Creates HTML reports with QA visualizations
  6. Optional Commit - Saves changes to DataLad repository if enabled

Preprocessing Requirements

Before running skullduggery, ensure your dataset:

  • Follows the BIDS standard
  • Provides age in subject sessions TSV/JSON files for longitudinal data, or in participants.tsv when session-level age is not defined. Participant age defaults to years unless its JSON sidecar specifies units (see age lookup).
  • Has anatomical images in proper BIDS format

Output Files

Skullduggery creates:

  • Defaced images - In-place modification of anatomical NIfTI files
  • Defacing masks - *desc-deface_mask.nii.gz files (if requested)
  • Transformation matrices - *_from-T1w_to-<template>_xfm.mat files
  • HTML reports - With registration and defacing visualizations
  • Metadata - DataLad metadata updates (if enabled)

Examples

Process All Participants

skullduggery /data/mybids

Process Specific Pediatric Cohort

skullduggery /data/mybids \
  --participant-label 001 002 003 \
  --template MNIInfant \
  --default-age 6:months

Generate Detailed Reports

skullduggery /data/mybids \
  --save-all-masks \
  --report-dir ./qa_reports \
  --debug debug

With Distribution Restrictions Filtering

skullduggery /data/mybids \
  --deface-sensitive \
  --datalad

Documentation

Contributing

See CONTRIBUTING.md for guidelines on reporting issues and contributing code.

License

This project is licensed under the MIT License. See LICENSE for details.

Citation

If you use Skullduggery in your research, please cite:

@software{skullduggery,
  title={Skullduggery: Automated Defacing of Neuroimaging Data},
  author={Pinsard, Basile},
  url={https://github.com/UNFmontreal/skullduggery},
  year={2024}
}

Support

For issues, questions, or suggestions, please open an issue on GitHub.

Docker release version

This change targets package and Docker version 0.0.7. After committing and reviewing the release, publishing Git tag 0.0.7 (or v0.0.7) triggers the Docker workflow and produces ghcr.io/unfmontreal/skullduggery:0.0.7. Branch builds keep their branch tags. The package version is defined in src/skullduggery/__init__.py; keep it aligned with the release tag.

Metadata

Release files for skullduggery 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skullduggery 0.0.7
File Size Uploaded Provenance Actions
skullduggery-0.0.7.tar.gz 196.1 kB Without provenance Details for skullduggery-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for skullduggery 0.0.7
File Interpreter ABI Platform Actions
skullduggery-0.0.7-py3-none-any.whl Python 3 none any Details for skullduggery-0.0.7-py3-none-any.whl

Total release size: 391.4 kB

Release files / skullduggery-0.0.7.tar.gz

Download URL skullduggery-0.0.7.tar.gz
Size 196.1 kB
Tags Source
SHA-256 checksum
How to use checksums
938c6415ba39e4af49f37495f3fb17f9c9e8a321579389d713efb0ca727198c0
BLAKE2b-256 checksum
How to use checksums
f76a8bdc868883cc01d5bab4d5a62f26f33f241eb4778ca24909a3f9856d9077
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Release files / skullduggery-0.0.7-py3-none-any.whl

Download URL skullduggery-0.0.7-py3-none-any.whl
Size 195.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b8d2a3a7ca64a3ebd1c9e213dbcb5346b0753fd09cbf49098963181bacbe9686
BLAKE2b-256 checksum
How to use checksums
b63ae625a4fb71438d5bd29a1d0d10d7bc5f212b7ebfe60992ba5fa2e380aa60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Security for skullduggery 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page