Skip to content

Integrate QC pipeline#55

Draft
K-Meech wants to merge 36 commits intomainfrom
km/qc-pipeline
Draft

Integrate QC pipeline#55
K-Meech wants to merge 36 commits intomainfrom
km/qc-pipeline

Conversation

@K-Meech
Copy link
Copy Markdown
Collaborator

@K-Meech K-Meech commented Apr 24, 2026

Closes #50 , Closes #9

Integrates the new QC workflow into the enigma-pd-wml pipeline:

  • Adds extra python dependencies needed for QC (mainly matplotlib). To allow both these dependencies and FSL to be managed together, I modified the Dockerfile to use miniforge to install dependencies listed in an environment.yaml file. This contains the set of FSL conda packages needed by the workflow + QC dependencies. The added benefit of this new approach is the overall image size is reduced by about 50%, by only doing a partial install of FSL.

  • Moves analysis_script.sh, and the new QC files (png_generator.py + MAKE_HTML.sh) into a sub-dir called src. This makes it easier to copy them all together in the Dockerfile, and makes them easier to find in the repo.

  • I made some modifications to the PNG_GENERATOR.sh script:

    • converted it into a python file png_generator.py, as it was mostly an embedded python file in a bash script
    • Updated the expected image paths to: results2mni_{reg_type}_combined.nii.gz
    • removed the subject / subjects.txt input parameter. To integrate with the rest of the pipeline it was easier to just pass a data_dir (the directory containing outputs for a single session), and outdir (the directory to write png images to). As the data_dir has a standard filepath structure, we can extract the subject / session ids directly from this.
    • previously, this script was called per-subject and would throw a warning if there were multiple sessions within a subject. This meant that only one session per subject could be browsed in the HTML files. To get around this, I now pass individual sessions to this script (rather than individual subjects), and results are written to the PNG dir in folders named like sub-1-ses-1, sub-1-ses-2 etc.
    • added some extra docstrings explaining what the parameters are
    • added skipping of PNG writing if the file already exists. This speeds up re-runs, if it failed part way through writing the PNGs or HTML images
  • I made some modifications to the MAKE_HTML.sh script.

    • Removed the subjects.txt input parameter - now it gets these names by listing the directories inside the PNG dir directly.
    • As the PNG dir now has one directory per session (rather than one per subject), all subjects and sessions will be included in the final HTML file. Ideally, we would change references to 'subject' in this file to 'scan' or similar (as the unit is now one scan from a single session, rather than a single subject) - it's mentioned in many different places though (across HTML, CSS, javascript and bash 😅) , so I didn't want to risk breaking things. I've added a comment above where the subject / session names are fetched - so hopefully this is clear enough.
    • I moved some lines from above the generate_html_for_registration function to below, as I think this is easier to follow (do move back if you would prefer though)
    • Added parsing of arguments from the command-line, matching the suggested usage
  • Updated non-bids processing to always write to a set output structure (matching the bids derivatives dir). This required adding a subject and session column to the input csv file (see updated non-bids-data.md)

  • Updated docs to match the new pipeline, and integrated the QC docs from the shared word doc (with some edits to fit it in with the rest of the docs). I split this into two files: qc_usage.md and qc_pipeline.md. One focuses on how to use the QC tool, while the other describes the technical details of how the QC pipeline works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate QC pipeline Use miniforge base image and install only required FSL packages

1 participant