Skip to content

Commit f3f6672

Browse files
authored
QOL updates (#21)
* Reorient CT to be PA * Update environment.yml * Bump version * Fix savepath * Make downloads verbose * Update DiffDRR version
1 parent 22a1dff commit f3f6672

8 files changed

Lines changed: 47 additions & 26 deletions

File tree

diffdrrdata/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.5"
1+
__version__ = "0.0.6"

diffdrrdata/deepfluoro.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def __getitem__(self, idx):
9797
.compose(self.world2camera.inverse())
9898
.compose(pose)
9999
.compose(self.anatomical2world)
100+
.compose(self.rot_180)
100101
)
101102
if self.rot_180_for_up(idx):
102103
img = torch.rot90(img, k=2)
@@ -118,11 +119,11 @@ def parse_volume(subject, bone_attenuation_multiplier, labels):
118119
# Get all parts of the volume
119120
volume = subject["vol/pixels"][:]
120121
volume = np.swapaxes(volume, 0, 2).copy()
121-
volume = torch.from_numpy(volume).unsqueeze(0) # .flip(1).flip(2)
122+
volume = torch.from_numpy(volume).unsqueeze(0).flip(1).flip(2)
122123

123124
mask = subject["vol-seg/image/pixels"][:]
124125
mask = np.swapaxes(mask, 0, 2).copy()
125-
mask = torch.from_numpy(mask).unsqueeze(0) # .flip(1).flip(2)
126+
mask = torch.from_numpy(mask).unsqueeze(0).flip(1).flip(2)
126127

127128
affine = np.eye(4)
128129
affine[:3, :3] = subject["vol/dir-mat"][:]
@@ -166,6 +167,8 @@ def parse_volume(subject, bone_attenuation_multiplier, labels):
166167
label_def=defns,
167168
fiducials=fiducials,
168169
)
170+
reorient = RigidTransform(torch.diag(torch.tensor([-1.0, -1.0, 1.0, 1.0])))
171+
subject.fiducials = reorient(subject.fiducials)
169172

170173
return subject, anatomical2world
171174

diffdrrdata/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
# %% ../notebooks/02_utils.ipynb 4
1313
def get_data_home() -> Path:
14-
"""By default, datasets are saved in `~/diffdrr_data`."""
15-
data_home = Path("~/diffdrr_data").expanduser()
14+
"""By default, datasets are saved in `~/user/diffdrr_data`."""
15+
data_home = data_home = Path("~/user/diffdrr_data").expanduser()
1616
data_home.mkdir(exist_ok=True)
1717
return data_home
1818

@@ -33,7 +33,7 @@ def load_file(filename: str):
3333
try:
3434
f = h5py.File(file_path)
3535
except FileNotFoundError:
36-
print(f"Downloading DeepFluoro dataset (~2.5 GB) to {file_path}")
36+
print(f"Downloading Ljubljana dataset (~1.0 GB) to {file_path}")
3737
download_ljubljana()
3838
f = h5py.File(file_path)
3939
else:
@@ -47,7 +47,7 @@ def download_deepfluoro():
4747
download_link = "http://archive.data.jhu.edu/api/access/datafile/:persistentId/?persistentId=doi:10.7281/T1/IFSXNV/EAN9GH"
4848
download_path = data_home / "ipcai_2020_full_res_data.zip"
4949
subprocess.run(
50-
f"wget -q --no-check-certificate -O {download_path} {download_link}".split(" ")
50+
f"wget --no-check-certificate -O {download_path} {download_link}".split(" ")
5151
)
5252
subprocess.run(f"unzip -o {download_path} -d {data_home}".split(" "))
5353
subprocess.run(f"rm {download_path}".split(" "))
@@ -58,7 +58,7 @@ def download_ljubljana():
5858
download_link = "https://drive.usercontent.google.com/download?id=1x585pGLI8QGk21qZ2oGwwQ9LMJ09Tqrx&confirm=xxx"
5959
download_path = data_home / "ljubljana.zip"
6060
subprocess.run(
61-
f"curl -s {download_link} -o {download_path} ".split(" ")
61+
f"curl {download_link} -o {download_path} ".split(" ")
6262
)
6363
subprocess.run(f"unzip -o {download_path} -d {data_home}".split(" "))
6464
subprocess.run(f"rm {download_path}".split(" "))

environment.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@ channels:
33
- conda-forge
44
dependencies:
55
- pip
6+
- pytorch>=2.2
7+
- einops
8+
- torchvision
9+
- torchio
10+
- kornia
11+
- timm
12+
- numpy
13+
- matplotlib
14+
- seaborn
15+
- imageio
16+
- fastcore
17+
- scipy
18+
- tqdm
19+
- pyvista
20+
- vtk
621
- h5py
722
- pip:
823
- diffdrr

notebooks/00_deepfluoro.ipynb

Lines changed: 13 additions & 10 deletions
Large diffs are not rendered by default.

notebooks/02_utils.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
"source": [
5757
"#| export\n",
5858
"def get_data_home() -> Path:\n",
59-
" \"\"\"By default, datasets are saved in `~/diffdrr_data`.\"\"\"\n",
60-
" data_home = Path(\"~/diffdrr_data\").expanduser()\n",
59+
" \"\"\"By default, datasets are saved in `~/user/diffdrr_data`.\"\"\"\n",
60+
" data_home = data_home = Path(\"~/user/diffdrr_data\").expanduser()\n",
6161
" data_home.mkdir(exist_ok=True)\n",
6262
" return data_home"
6363
]
@@ -86,7 +86,7 @@
8686
" try:\n",
8787
" f = h5py.File(file_path)\n",
8888
" except FileNotFoundError:\n",
89-
" print(f\"Downloading DeepFluoro dataset (~2.5 GB) to {file_path}\")\n",
89+
" print(f\"Downloading Ljubljana dataset (~1.0 GB) to {file_path}\")\n",
9090
" download_ljubljana()\n",
9191
" f = h5py.File(file_path)\n",
9292
" else:\n",
@@ -108,7 +108,7 @@
108108
" download_link = \"http://archive.data.jhu.edu/api/access/datafile/:persistentId/?persistentId=doi:10.7281/T1/IFSXNV/EAN9GH\"\n",
109109
" download_path = data_home / \"ipcai_2020_full_res_data.zip\"\n",
110110
" subprocess.run(\n",
111-
" f\"wget -q --no-check-certificate -O {download_path} {download_link}\".split(\" \")\n",
111+
" f\"wget --no-check-certificate -O {download_path} {download_link}\".split(\" \")\n",
112112
" )\n",
113113
" subprocess.run(f\"unzip -o {download_path} -d {data_home}\".split(\" \"))\n",
114114
" subprocess.run(f\"rm {download_path}\".split(\" \"))"
@@ -127,7 +127,7 @@
127127
" download_link = \"https://drive.usercontent.google.com/download?id=1x585pGLI8QGk21qZ2oGwwQ9LMJ09Tqrx&confirm=xxx\"\n",
128128
" download_path = data_home / \"ljubljana.zip\"\n",
129129
" subprocess.run(\n",
130-
" f\"curl -s {download_link} -o {download_path} \".split(\" \")\n",
130+
" f\"curl {download_link} -o {download_path} \".split(\" \")\n",
131131
" )\n",
132132
" subprocess.run(f\"unzip -o {download_path} -d {data_home}\".split(\" \"))\n",
133133
" subprocess.run(f\"rm {download_path}\".split(\" \"))"

notebooks/deepfluoro_camera_poses.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

settings.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[DEFAULT]
22
repo = DiffDRR-Datasets
33
lib_name = diffdrrdata
4-
version = 0.0.5
4+
version = 0.0.6
55
min_python = 3.7
66
license = apache2
77
black_formatting = False
@@ -26,7 +26,7 @@ keywords = nbdev jupyter notebook python
2626
language = English
2727
status = 3
2828
user = eigenvivek
29-
requirements = diffdrr>=0.4.6 h5py
29+
requirements = diffdrr>=0.5.0 h5py
3030
readme_nb = index.ipynb
3131
allowed_metadata_keys =
3232
allowed_cell_metadata_keys =

0 commit comments

Comments
 (0)