-
Notifications
You must be signed in to change notification settings - Fork 2
Update batch_single_subject.sh for the 2025 SCT Course
#33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
5ca1c2a
Temporarily turn off PR trigger on workflows
joshuacwnewton bd48328
Add GHA workflow to diff slides with batch script
joshuacwnewton 33fcc22
Replace `sct_label_vertebrae` with disc labels from `totalspineseg`
joshuacwnewton a6d80ca
Replace `sct_deepseg_gm` with `sct_deepseg graymatter`
joshuacwnewton 06c0161
Replace `sct_deepseg_sc` with `sct_deepseg spinalcord`
joshuacwnewton b31a5bd
Add missing lumbar `sct_qc` command
joshuacwnewton bd6c4c1
Uncomment `sct_analyze_lesion -f` command
joshuacwnewton 0eb1aec
Add space to commented-out `sct_label_utils` command
joshuacwnewton 4ab8bbc
Add new `sct_compute_ascor` command
joshuacwnewton 53665c3
Temporarily commit course text to make testing easier
joshuacwnewton 3c42572
Revert "Temporarily commit course text to make testing easier"
joshuacwnewton bfe9286
Revert "Temporarily turn off PR trigger on workflows"
joshuacwnewton c98f50b
Fix `-step1-only` syntax
joshuacwnewton 8812617
`gmseg` -> `gm_seg` to match new `graymatter` output
joshuacwnewton cd149da
`batch_single_subject.sh`: Fix `aSCOR` typo (`-1` -> `1`)
joshuacwnewton 60ebdeb
`batch_single_subject.sh`: Revert back to `_gmseg`
joshuacwnewton e51c8fb
`batch_single_subject.sh`: Add cmd to generate `t2_seg_labeled.nii.gz`
joshuacwnewton dc8264a
`batch_single_subject.sh`: Remove sct_label_vertebrae comments
joshuacwnewton aa88fb2
`batch_single_subject.sh`: Update totalspineseg syntax/output fname
joshuacwnewton 8719e48
`batch_single_subject.sh`: Update tutorial-specific command
joshuacwnewton fd6d63d
`batch_single_subject.sh`: Add cropping step to improve `sc_epi`
joshuacwnewton 93cddf5
`run_script_and_create_release.yml`: Upload QC artifact
joshuacwnewton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Compare SCT Commands | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| text_url: | ||
| description: "URL to text file (e.g. GitHub raw gist link)" | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| compare: | ||
| runs-on: macos-latest | ||
| env: | ||
| YDIFF_OPTIONS: "--unified --pager=cat --color=always --width=120 --nowrap" | ||
|
|
||
| steps: | ||
| - name: Check out repo | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install Python (for parsing script) | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
|
|
||
| - name: Install `ydiff` # https://github.com/ymattw/ydiff | ||
| run: brew install ydiff | ||
|
|
||
| - name: Download remote text file | ||
| run: | | ||
| curl -L ${{ inputs.text_url }} -o remote.txt | ||
| echo "✅ Downloaded remote file:" | ||
| wc -l remote.txt | ||
|
|
||
| - name: Extract commands from remote file | ||
| run: | | ||
| python3 .github/workflows/scripts/extract_sct.py remote.txt -o remote_cmds.txt | ||
| sort -u remote_cmds.txt > remote_cmds_sorted.txt | ||
| echo "✅ Extracted $(wc -l < remote_cmds_sorted.txt) commands from remote file" | ||
|
|
||
| - name: Extract commands from local batch script | ||
| run: | | ||
| python3 .github/workflows/scripts/extract_sct.py single_subject/batch_single_subject.sh -o local_cmds.txt | ||
| sort -u local_cmds.txt > local_cmds_sorted.txt | ||
| echo "✅ Extracted $(wc -l < local_cmds_sorted.txt) commands from local script" | ||
|
|
||
| - name: Diff commands | ||
| run: | | ||
| echo "🔍 Diffing remote vs local..." | ||
| diff -u local_cmds_sorted.txt remote_cmds_sorted.txt > diff.txt || true | ||
| ydiff < diff.txt | ||
|
|
||
| - name: Upload results as artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: command-diff-output | ||
| path: | | ||
| remote_cmds_sorted.txt | ||
| local_cmds_sorted.txt | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import argparse | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| def extract_sct_commands(paths, output=None): | ||
| results = [] | ||
|
|
||
| for path in paths: | ||
| with open(path, "r", encoding="utf-8") as f: | ||
| for line in f: | ||
| stripped = line.lstrip() | ||
| if stripped.startswith("# sct_"): | ||
| stripped = stripped[2:] | ||
| # Find relavent SCT commands to compare | ||
| if (stripped.startswith("sct_") | ||
| # sct commands must have command + arg + value (3) | ||
| # this excludes slide subtitles like "sct_slide ..." | ||
| and len(stripped.split(" ")) >= 3 | ||
| # exclude lines with <> which are likely placeholders | ||
| and not ("<" in stripped and ">" in stripped) | ||
| # exclude sct_download_data (data already present) | ||
| and not stripped.startswith("sct_download_data") | ||
| # exclude sct_run_batch (handled in .yml workflow) | ||
| and not stripped.startswith("sct_run_batch")): | ||
| results.append(stripped.rstrip()) | ||
|
|
||
| if output: | ||
| Path(output).write_text("\n".join(results), encoding="utf-8") | ||
| else: | ||
| print("\n".join(results)) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| parser = argparse.ArgumentParser(description="Extract SCT commands " | ||
| "from TXT files.") | ||
| parser.add_argument("files", nargs="+", help="Input text files") | ||
| parser.add_argument("-o", "--output", help="Optional output file") | ||
| args = parser.parse_args() | ||
|
|
||
| extract_sct_commands(args.files, args.output) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.