Skip to content

Commit bfaf6b0

Browse files
committed
updated docker files
1 parent 26dd3c1 commit bfaf6b0

8 files changed

Lines changed: 78 additions & 28 deletions

File tree

brainbuilder/interp/acqvolume.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import numpy as np
77
import pandas as pd
8-
import stripy as stripy
98
from scipy.interpolate import interp1d
109
from scipy.ndimage import gaussian_filter, label
1110

brainbuilder/interp/surfinterp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import nibabel as nb_surf
77
import numpy as np
88
import pandas as pd
9-
import stripy as stripy
109
from joblib import Parallel, delayed
1110

1211
import brainbuilder.utils.ants_nibabel as nib
@@ -527,6 +526,7 @@ def interpolate_over_surface(
527526
)
528527

529528
# create mesh data structure
529+
import stripy as stripy
530530
mesh = stripy.sTriangulation(lons_src, lats_src)
531531

532532
lats, lons = spherical_coords[:, 1] - np.pi / 2, spherical_coords[:, 2]

brainbuilder/tests/generate_synthetic_data.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def save_coronal_sections(input_fn:str, out_dir:str, raw_dir:str, sub:str, hemis
8282
continue
8383

8484
save_section(input_vol, y, affine, raw_sec_fn)
85+
print(raw_sec_fn)
8586

8687
row_dict = {
8788
"raw": [raw_sec_fn],
@@ -144,9 +145,9 @@ def generate_synthetic_data(
144145
"sub": [sub],
145146
"chunk": [chunk],
146147
"hemisphere": [hemisphere],
147-
"pixel_size_0": [1],
148-
"pixel_size_1": [1],
149-
"section_thickness": [1],
148+
"pixel_size_0": [1.0],
149+
"pixel_size_1": [1.0],
150+
"section_thickness": [1.0],
150151
"direction": ["caudal_to_rostral"],
151152
}
152153
)

brainbuilder/utils/validate_inputs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def val_func(x: Union[int, float, str]) -> bool:
5959
return True
6060

6161
if n_jobs is None:
62-
n_jobs = int(cpu_count() / 2)
62+
n_jobs = int(cpu_count() )
6363

6464
validated_rows = Parallel(n_jobs=n_jobs)(
6565
delayed(val_func)(var) for var in rows
@@ -124,6 +124,7 @@ def validate_dataframe(
124124
validated = column.validate_rows_in_column(
125125
df[column.name].values, n_jobs=n_jobs
126126
)
127+
print(column.name, validated)
127128
valid_columns.append(validated)
128129

129130
valid_inputs = np.product(np.array(valid_columns))
@@ -238,16 +239,17 @@ def validate_inputs(
238239

239240
if not valid_inputs:
240241
print("\nValidating Hemi Info")
241-
hemi_info_valid = validate_csv(
242-
hemi_info_csv, hemi_info_required_columns, n_jobs=n_jobs
243-
)
244-
print("\tHemi Info Valid =", bool(hemi_info_valid))
242+
#hemi_info_valid = validate_csv(
243+
# hemi_info_csv, hemi_info_required_columns, n_jobs=n_jobs
244+
#)
245+
#print("\tHemi Info Valid =", bool(hemi_info_valid))
245246

246247
print("\nValidating Chunk Info")
247248
chunk_info_valid = validate_csv(
248249
chunk_info_csv, chunk_info_required_columns, n_jobs=n_jobs
249250
)
250251
print("\tChunk Info Valid =", bool(chunk_info_valid))
252+
exit()
251253

252254
print("\nValidating Sect Info")
253255
sect_info_valid = validate_csv(

docker/Dockerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM tffunck/brainbuilder:base
2+
3+
SHELL ["/bin/bash", "-c"]
4+
RUN cd /opt && \
5+
rm -fr brainbuilder && \
6+
git clone https://www.github.com/tfunck/brainbuilder &&\
7+
cd brainbuilder &&\
8+
/opt/bbenv/bin/pip3 install -r requirements.txt &&\
9+
/opt/bbenv/bin/pip3 install .
10+
11+
# Create the entrypoint.sh script
12+
RUN echo '#!/bin/bash' > /opt/entrypoint.sh && \
13+
echo 'source /opt/bbenv/bin/activate' >> /opt/entrypoint.sh && \
14+
echo 'exec "$@"' >> /opt/entrypoint.sh
15+
16+
# Make the script executable
17+
RUN chmod +x /opt/entrypoint.sh
18+
ENTRYPOINT ["/opt/entrypoint.sh"]
19+
RUN pwd

docker/base/Dockerfile

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM antsx/ants
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
# Install system dependencies
6+
RUN apt update && apt upgrade -y && \
7+
apt-get install -y \
8+
git \
9+
curl\
10+
python3 python3-dev python3-venv python3-pip\
11+
python3-opencv \
12+
libglib2.0-0 \
13+
build-essential libssl-dev\
14+
cmake
15+
16+
# Install any python packages you need
17+
WORKDIR /opt
18+
19+
RUN cd /opt && \
20+
python3 -m venv bbenv &&\
21+
git clone https://www.github.com/tfunck/brainbuilder && \
22+
cd brainbuilder && \
23+
/opt/bbenv/bin/pip3 install -r requirements.txt
24+
25+
26+
27+

notebooks/tutorial.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
# CELL 1
22
from brainbuilder.tests.generate_synthetic_data import generate_synthetic_data
3-
3+
import os
4+
5+
default_path = os.path.realpath(os.path.dirname(os.path.abspath(__file__))+'/../')+'/'
6+
47
generate_synthetic_data(
5-
input_fn = '../data/mni_icbm152_01_tal_nlin_asym_09c.nii.gz',
6-
out_dir = '../data/mni152_test',
7-
gm_surf_fn = '../data/MR1_gray_surface_R_81920.surf.gii',
8-
wm_surf_fn = '../data/MR1_white_surface_R_81920.surf.gii',
9-
clobber = False
8+
input_fn = f'{default_path}data/mni_icbm152_01_tal_nlin_asym_09c.nii.gz',
9+
out_dir = f'{default_path}data/mni152_test',
10+
gm_surf_fn = f'{default_path}data/MR1_gray_surface_R_81920.surf.gii',
11+
wm_surf_fn = f'{default_path}data/MR1_white_surface_R_81920.surf.gii',
12+
clobber = True
1013
)
1114

15+
16+
def realpath(x) : return os.path.realpath(default_path+x)
17+
1218
# CELL 2
1319
import pandas as pd
1420

15-
sect_info_csv = "../data/mni152_test/sect_info.csv"
16-
chunk_info_csv = "../data/mni152_test/chunk_info.csv"
17-
hemi_info_csv = "../data/mni152_test/hemi_info.csv"
21+
sect_info_csv = f"{default_path}data/mni152_test/sect_info.csv"
22+
chunk_info_csv = f"{default_path}data/mni152_test/chunk_info.csv"
23+
hemi_info_csv = f"{default_path}data/mni152_test/hemi_info.csv"
24+
1825

1926
# Load the sect_info csv and visualize contents. Stores section-wise information
2027
print('Sect Info:')
@@ -43,6 +50,6 @@
4350
chunk_info_csv,
4451
sect_info_csv,
4552
[4, 3, 2, 1],
46-
"tests/data/mni152_test_output/",
53+
f"{default_path}/data/mni152_test_output/",
4754
clobber=False,
4855
)

requirements.txt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
1-
numpy
1+
numpy<2
2+
stripy
23
scipy
34
pandas
4-
stripy
55
h5py
6-
guppy3
76
psutil
87
statsmodels
98
configparser
109
scikit-learn
1110
scikit-image
1211
SimpleITK
1312
imageio
14-
keras
15-
pydot
1613
matplotlib
1714
nibabel
1815
seaborn
19-
torch
20-
torchvision
2116
antspyx
2217
pre-commit
2318
webcolors
2419
ruff
2520
pre-commit
2621
nnunet
2722
nnunetv2
28-
medpy
23+
medpy

0 commit comments

Comments
 (0)