Skip to content

Commit 7d0e898

Browse files
committed
merged
2 parents 93b92d4 + e7e96d5 commit 7d0e898

10 files changed

Lines changed: 73 additions & 27 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/qc/validate_interp_error.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,6 @@ def validate_interp_error(
726726
output_sect_info_csv = f"{output_dir}/validate_interp_error_sect_info.csv"
727727
sect_info = pd.read_csv(sect_info_csv)
728728
chunk_info = pd.read_csv(chunk_info_csv)
729-
print(sect_info["img"].values[0:10])
730-
exit(0)
731729

732730
# Only keep highest resolution in chunk_info
733731
chunk_info = chunk_info.loc[

brainbuilder/tests/generate_synthetic_data.py

Lines changed: 4 additions & 5 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],
@@ -135,18 +136,16 @@ def generate_synthetic_data(
135136
for dir_path in [out_dir, raw_dir]:
136137
os.makedirs(dir_path, exist_ok=True)
137138

138-
139139
save_coronal_sections(input_fn, out_dir, raw_dir, sub, hemisphere, chunk, ystep=ystep, clobber=clobber )
140140

141-
142141
chunk_info_df = pd.DataFrame(
143142
{
144143
"sub": [sub],
145144
"chunk": [chunk],
146145
"hemisphere": [hemisphere],
147-
"pixel_size_0": [1],
148-
"pixel_size_1": [1],
149-
"section_thickness": [1],
146+
"pixel_size_0": [1.0],
147+
"pixel_size_1": [1.0],
148+
"section_thickness": [1.0],
150149
"direction": ["caudal_to_rostral"],
151150
}
152151
)

brainbuilder/utils/validate_inputs.py

Lines changed: 2 additions & 1 deletion
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))

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+

docker/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build -t tffunck/brainbuilder:v.1 -t tffunck/brainbuilder:latest .

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: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1+
numpy<2
12
stripy
3+
scipy
24
pandas
35
h5py
4-
guppy3
56
psutil
67
statsmodels
78
configparser
89
scikit-learn
910
scikit-image
1011
SimpleITK
1112
imageio
12-
keras
13-
pydot
1413
matplotlib
1514
nibabel
1615
seaborn
17-
torch
18-
torchvision
1916
antspyx
2017
pre-commit
2118
webcolors
@@ -24,5 +21,3 @@ pre-commit
2421
nnunet
2522
nnunetv2
2623
medpy
27-
numpy<2
28-
scipy

0 commit comments

Comments
 (0)