-
Notifications
You must be signed in to change notification settings - Fork 1
ENH: Convert python notebooks to python scripts (with percent tags to define cells) #41
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 17 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ab46512
MNT: Convert experiments/Colormap-VTK_To_USD notebooks to py:percent …
aylward c37a96c
MNT: Convert experiments/Convert_VTK_To_USD notebooks to py:percent s…
aylward 912ae3f
MNT: Convert experiments/Heart-Create_Statistical_Model notebooks to …
aylward af33296
MNT: Convert experiments/Heart-VTKSeries_To_USD notebooks to py:perce…
aylward 3bb3d3d
MNT: Convert experiments/Heart-GatedCT_To_USD notebooks to py:percent…
aylward 7d30f70
MNT: Convert experiments/Heart-Statistical_Model_To_Patient notebooks…
aylward 2ce03c7
MNT: Convert experiments/Lung-GatedCT_To_USD notebooks to py:percent …
aylward 0a789d8
MNT: Convert experiments/Reconstruct4DCT notebooks to py:percent scripts
aylward f3eb18f
MNT: Convert experiments/Heart-Simpleware_Segmentation notebooks to p…
aylward 12f0baa
MNT: Convert experiments/DisplacementField_To_USD notebooks to py:per…
aylward 70ec93f
MNT: Convert experiments/Lung-VesselsAirways notebooks to py:percent …
aylward a3120e3
MNT: Convert data/DirLab-4DCT notebooks to py:percent scripts
aylward fda40d8
MNT: Convert data/Slicer-Heart-CT notebooks to py:percent scripts
aylward de48fd6
MNT: Anchor all experiment script paths to __file__
aylward c74b5de
DOC: Update docs to reflect py:percent experiment scripts
aylward f4a0366
FIX: Remove emoji from test output to fix Windows cp1252 encoding
aylward 60992ac
MNT: Remove emojis from test_experiments.py output and docstrings
aylward 2e22084
STYLE: Update based on CoPilot and CodeRabbit reviews
aylward 5ce9813
FIX: Fix bugs, dead code, and stale references flagged by Copilot/Cod…
aylward 5f91df6
FIX: Fix spatial misalignment, typos, and stale comments in experiments
aylward fb9ae1f
FIX: Use Rigid (not Affine) ICP and guard against empty mesh list
aylward d19118c
DOC: Correct ICP registration docs to say Affine (not Rigid)
aylward 3357bd0
STYLE: copilot reporting of ruff / unused vars
aylward 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 was deleted.
Oops, something went wrong.
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,74 @@ | ||
| #!/usr/bin/env python | ||
| # %% | ||
| import os | ||
|
|
||
| # %% | ||
| sizes = [ | ||
| [256, 256, 94], | ||
| [256, 256, 112], | ||
| [256, 256, 104], | ||
| [256, 256, 99], | ||
| [256, 256, 106], | ||
| [512, 512, 128], | ||
| [512, 512, 136], | ||
| [512, 512, 128], | ||
| [512, 512, 128], | ||
| [512, 512, 120], | ||
| ] | ||
| spacings = [ | ||
| [0.97, 0.97, 2.5], | ||
| [1.16, 1.16, 2.5], | ||
| [1.15, 1.15, 2.5], | ||
| [1.13, 1.13, 2.5], | ||
| [1.10, 1.10, 2.5], | ||
| [0.97, 0.97, 2.5], | ||
| [0.97, 0.97, 2.5], | ||
| [0.97, 0.97, 2.5], | ||
| [0.97, 0.97, 2.5], | ||
| [0.97, 0.97, 2.5], | ||
| ] | ||
| files = [ | ||
| "Case1Pack", | ||
| "Case2Pack", | ||
| "Case3Pack", | ||
| "Case4Pack", | ||
| "Case5Pack", | ||
| "Case6Pack", | ||
| "Case7Pack", | ||
| "Case8Deploy", | ||
| "Case9Pack", | ||
| "Case10Pack", | ||
| ] | ||
| file_suffix = [ | ||
| "_s", | ||
| "-ssm", | ||
| "-ssm", | ||
| "-ssm", | ||
| "-ssm", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| "", | ||
| ] | ||
|
|
||
| # %% | ||
| for file_num, file_name in enumerate(files): | ||
| spacing = f"{spacings[file_num][0]} {spacings[file_num][1]} {spacings[file_num][2]}" | ||
| size = f"{sizes[file_num][0]} {sizes[file_num][1]} {sizes[file_num][2]}" | ||
| for phase in range(10): | ||
| img_path = f"{file_name}/Images/case{file_num + 1}_T{phase * 10:02d}{file_suffix[file_num]}.img" | ||
| script_dir = os.getcwd() | ||
| hdr_path = f"{script_dir}/{file_name}_T{phase * 10:02d}.mhd" | ||
| with open(hdr_path, "w") as f: | ||
| f.write("ObjectType = Image\n") | ||
| f.write("NDims = 3\n") | ||
| f.write(f"DimSize = {size}\n") | ||
| f.write("HeaderSize = -1\n") | ||
| f.write("BinaryData = True\n") | ||
| f.write("BinaryDataByteOrderMSB = False\n") | ||
| f.write("Orientation = 1 0 0 0 1 0 0 0 -1\n") | ||
| f.write(f"ElementSpacing = {spacing}\n") | ||
| f.write("ElementType = MET_SHORT\n") | ||
| f.write("ElementNumberOfChannels = 1\n") | ||
| f.write(f"ElementDataFile = {img_path}\n") |
This file was deleted.
Oops, something went wrong.
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,32 @@ | ||
| #!/usr/bin/env python | ||
| # %% | ||
| import os | ||
| import shutil | ||
| import urllib | ||
|
|
||
| from physiomotion4d.convert_nrrd_4d_to_3d import ConvertNRRD4DTo3D | ||
|
|
||
| # %% | ||
| data_dir = "." | ||
| output_dir = "." | ||
|
|
||
| if not os.path.exists(data_dir): | ||
| os.makedirs(data_dir, exist_ok=True) | ||
|
|
||
| if not os.path.exists(output_dir): | ||
| os.makedirs(output_dir, exist_ok=True) | ||
|
|
||
| # %% | ||
| input_image_url = "https://github.com/SlicerHeart/SlicerHeart/releases/download/TestingData/TruncalValve_4DCT.seq.nrrd" | ||
| input_image_filename = os.path.join(data_dir, "TruncalValve_4DCT.seq.nrrd") | ||
|
|
||
| if not os.path.exists(input_image_filename): | ||
| urllib.request.urlretrieve(input_image_url, input_image_filename) | ||
|
|
||
| # %% | ||
| conv = ConvertNRRD4DTo3D() | ||
| conv.load_nrrd_4d(f"{data_dir}/TruncalValve_4DCT.seq.nrrd") | ||
| conv.save_3d_images(f"{output_dir}/slice") | ||
|
|
||
| # Save the mid-stroke slice as the fixed/reference image | ||
| shutil.copyfile(f"{output_dir}/slice_007.mha", f"{output_dir}/slice_fixed.mha") | ||
Oops, something went wrong.
Oops, something went wrong.
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.