Skip to content
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

add lib versioning #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions ivadomed/scripts/prepare_dataset_vertebral_labeling.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ def mask2label(path_label, aim=0):
return list_label_image


def create_fake_nib_image():
timepoints = 200
nvox = 20

# Creates fake data to test with
test_data = np.random.random((nvox, nvox, nvox, timepoints))
time = np.linspace(0, 400, timepoints)
freq = 1
test_data = test_data + np.sin(2 * np.pi * freq * time)
xform = np.eye(4) * 2
test_img = nib.nifti1.Nifti1Image(test_data, xform)
return test_img


def extract_mid_slice_and_convert_coordinates_to_heatmaps(path, suffix, aim=-1):
"""
This function takes as input a path to a dataset and generates a set of images:
Expand Down Expand Up @@ -69,15 +83,13 @@ def extract_mid_slice_and_convert_coordinates_to_heatmaps(path, suffix, aim=-1):
sub = t[i]
path_image = os.path.join(path, t[i], 'anat', t[i] + suffix + '.nii.gz')
if os.path.isfile(path_image):
path_label = os.path.join(path, 'derivatives', 'labels', t[i], 'anat', t[i] + suffix +
'_labels-disc-manual.nii.gz')
list_points = mask2label(path_label, aim=aim)
list_points = [[0, 0, 0, 0]]
image_ref = nib.load(path_image)
nib_ref_can = nib.as_closest_canonical(image_ref)
imsh = np.array(nib_ref_can.dataobj).shape
mid_nifti = imed_preprocessing.get_midslice_average(path_image, list_points[0][0], slice_axis=0)
nib.save(mid_nifti, os.path.join(path, t[i], 'anat', t[i] + suffix + '_mid.nii.gz'))
lab = nib.load(path_label)
lab = create_fake_nib_image()
nib_ref_can = nib.as_closest_canonical(lab)
label_array = np.zeros(imsh[1:])

Expand Down
20 changes: 10 additions & 10 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
bids-neuropoly>=0.2
csv-diff>=1.0
h5py==2.10.0
joblib
joblib~=1.0
matplotlib>=3.3.0
nibabel
nibabel~=3.2
onnxruntime==1.4.0
pandas
pandas~=1.1
pillow>=7.0.0
pybids>=0.12.4
pytest
pytest~=6.2
scikit-learn>=0.20.3
scikit-image
seaborn
tensorboard
scikit-image~=0.17
seaborn~=0.11
tensorboard~=2.4
torch==1.5.0
torchvision==0.6.0
tqdm>=4.30
pytest-ordering
sphinx-jsonschema
pytest-console-scripts
pytest-ordering~=0.6
sphinx-jsonschema~=1.16
pytest-console-scripts~=1.1
pre-commit==2.10.1
8 changes: 1 addition & 7 deletions testing/functional_tests/test_visualize_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ def test_visualize_transforms_n_1():
__input_file__ = os.path.join(__data_testing_dir__, 'sub-unf01/anat/sub-unf01_T1w.nii.gz')
__output_dir__ = os.path.join(__tmp_dir__, "output_visualize_transforms_n_1")
__config_file__ = os.path.join(__data_testing_dir__, "model_config.json")
__label_file__ = os.path.join(__data_testing_dir__,
'derivatives/labels/sub-test001/anat/sub-unf01_T1w_seg-manual.nii.gz')
visualize_transforms.main(args=['--input', __input_file__,
'--output', __output_dir__,
'--config', __config_file__,
'-r', __label_file__])
'--config', __config_file__])
assert os.path.exists(__output_dir__)
output_files = os.listdir(__output_dir__)
assert len(output_files) == 5
Expand All @@ -33,12 +30,9 @@ def test_visualize_transforms_n_2():
__input_file__ = os.path.join(__data_testing_dir__, 'sub-unf01/anat/sub-unf01_T1w.nii.gz')
__output_dir__ = os.path.join(__tmp_dir__, "output_visualize_transforms_n_2")
__config_file__ = os.path.join(__data_testing_dir__, "model_config.json")
__label_file__ = os.path.join(__data_testing_dir__,
'derivatives/labels/sub-test001/anat/sub-unf01_T1w_seg-manual.nii.gz')
visualize_transforms.main(args=['--input', __input_file__,
'--output', __output_dir__,
'--config', __config_file__,
'-r', __label_file__,
'-n', '2'])
assert os.path.exists(__output_dir__)
output_files = os.listdir(__output_dir__)
Expand Down