From c9d218526ec20407f88e5df7b8ee555ff0ec02e3 Mon Sep 17 00:00:00 2001 From: EmmaRenauld Date: Wed, 17 Jan 2024 09:40:52 -0500 Subject: [PATCH 1/5] Change requirements. Require latest master scilpy for gdrive fetcher --- .gitignore | 3 ++- requirements.txt | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 2ced2f93..29dc28a4 100644 --- a/.gitignore +++ b/.gitignore @@ -71,4 +71,5 @@ target/ *.swo # dwi_ml stuff -.ipynb_config/ \ No newline at end of file +.ipynb_config/ +.ipynb_checkpoints/ \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index ca74400a..28c900f6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,18 @@ # Supported for python 3.10 # Should work for python > 3.8. -# Scilpy and comet_ml both require requests. In comet: >=2.18.*, -# which installs a version >2.28. Adding request version explicitely. +# ------- +# Main dependency: scilpy +# Scilpy and comet_ml both require requests. In comet: >=2.18.*, +# which installs a version >2.28. Adding request version explicitely. +# ------- requests==2.28.* +-e git+https://github.com/scilus/scilpy.git#egg=scilpy + + +# ------- +# Other important dependencies +# ------- bertviz~=1.4.0 # For transformer's visu torch==1.13.* tqdm==4.64.* @@ -11,20 +20,20 @@ comet-ml==3.21.* contextlib2==21.6.0 jupyterlab>=3.6.2 # For transformer's visu IProgress>=0.4 # For jupyter with tdqm -nested_lookup==0.2.25 -nose==1.3.* -scilpy==1.5.post2 +nested_lookup==0.2.25 # For lists management +# ################# nose==1.3.* -## Necessary but should be installed with scilpy (Last check: 09/2023): +# ------- +# Necessary but should be installed with scilpy (Last check: 09/2023): +# ------- future==0.18.* h5py==3.7.* # h5py must absolutely be >2.4: that's when it became thread-safe matplotlib==3.6.* # Hint: If matplotlib fails, you may try to install pyQt5. -nibabel==4.0.* +nibabel==5.2.* numpy==1.23.* scipy==1.9.* - # --------------- Notes to developers # If we upgrade torch, verify if code copied in # models.projects.transformers_from_torch has changed. From 99d31395ecb784031b8bcd8ac54915cb6de3f990 Mon Sep 17 00:00:00 2001 From: EmmaRenauld Date: Wed, 17 Jan 2024 09:58:28 -0500 Subject: [PATCH 2/5] Make changes to follow latest scilpy architecture --- dwi_ml/data/processing/dwi/dwi.py | 3 ++- dwi_ml/data/processing/streamlines/data_augmentation.py | 3 ++- dwi_ml/data/processing/streamlines/post_processing.py | 2 +- dwi_ml/testing/projects/transformer_visualisation_utils.py | 3 ++- dwi_ml/tracking/io_utils.py | 6 +++--- dwi_ml/tracking/tracker.py | 5 ++--- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/dwi_ml/data/processing/dwi/dwi.py b/dwi_ml/data/processing/dwi/dwi.py index d28734bc..48decfff 100644 --- a/dwi_ml/data/processing/dwi/dwi.py +++ b/dwi_ml/data/processing/dwi/dwi.py @@ -5,8 +5,9 @@ from dipy.reconst.shm import sph_harm_lookup import nibabel as nib import numpy as np + from scilpy.io.utils import validate_sh_basis_choice -from scilpy.reconst.raw_signal import compute_sh_coefficients +from scilpy.reconst.sh import compute_sh_coefficients eps = 1e-6 diff --git a/dwi_ml/data/processing/streamlines/data_augmentation.py b/dwi_ml/data/processing/streamlines/data_augmentation.py index 14634525..60d04adf 100644 --- a/dwi_ml/data/processing/streamlines/data_augmentation.py +++ b/dwi_ml/data/processing/streamlines/data_augmentation.py @@ -8,7 +8,8 @@ from nibabel.streamlines.tractogram import (PerArrayDict, PerArraySequenceDict) import numpy as np -from scilpy.tracking.tools import resample_streamlines_step_size +from scilpy.tractograms.streamline_operations import \ + resample_streamlines_step_size from scilpy.utils.streamlines import compress_sft diff --git a/dwi_ml/data/processing/streamlines/post_processing.py b/dwi_ml/data/processing/streamlines/post_processing.py index f83360f5..f09e3186 100644 --- a/dwi_ml/data/processing/streamlines/post_processing.py +++ b/dwi_ml/data/processing/streamlines/post_processing.py @@ -6,7 +6,7 @@ from scilpy.tractanalysis.tools import \ extract_longest_segments_from_profile as segmenting_func -from scilpy.tractanalysis.uncompress import uncompress +from scilpy.tractograms.uncompress import uncompress # We could try using nan instead of zeros for non-existing previous dirs... DEFAULT_UNEXISTING_VAL = torch.zeros((1, 3), dtype=torch.float32) diff --git a/dwi_ml/testing/projects/transformer_visualisation_utils.py b/dwi_ml/testing/projects/transformer_visualisation_utils.py index 26803485..c19dcfcd 100644 --- a/dwi_ml/testing/projects/transformer_visualisation_utils.py +++ b/dwi_ml/testing/projects/transformer_visualisation_utils.py @@ -10,7 +10,8 @@ from scilpy.io.streamlines import load_tractogram_with_reference from scilpy.io.utils import add_reference_arg, add_overwrite_arg, add_bbox_arg -from scilpy.tracking.tools import resample_streamlines_step_size +from scilpy.tractograms.streamline_operations import \ + resample_streamlines_step_size from scilpy.utils.streamlines import compress_sft from dwi_ml.io_utils import add_logging_arg diff --git a/dwi_ml/tracking/io_utils.py b/dwi_ml/tracking/io_utils.py index fbb011e3..a27735de 100644 --- a/dwi_ml/tracking/io_utils.py +++ b/dwi_ml/tracking/io_utils.py @@ -129,18 +129,18 @@ def prepare_seed_generator(parser, args, hdf_handle): seed_generator = SeedGenerator(seed_data, seed_res, space=ALWAYS_VOX_SPACE, origin=ALWAYS_CORNER) - if len(seed_generator.seeds_vox) == 0: + if len(seed_generator.seeds_vox_corner) == 0: parser.error('Seed mask "{}" does not have any voxel with value > 0.' .format(args.in_seed)) if args.npv: # Note. Not really nb seed per voxel, just in average. - nbr_seeds = len(seed_generator.seeds_vox) * args.npv + nbr_seeds = len(seed_generator.seeds_vox_corner) * args.npv elif args.nt: nbr_seeds = args.nt else: # Setting npv = 1. - nbr_seeds = len(seed_generator.seeds_vox) + nbr_seeds = len(seed_generator.seeds_vox_corner) seed_header = nib.Nifti1Image(seed_data, affine).header diff --git a/dwi_ml/tracking/tracker.py b/dwi_ml/tracking/tracker.py index eb6894a3..d27503e8 100644 --- a/dwi_ml/tracking/tracker.py +++ b/dwi_ml/tracking/tracker.py @@ -399,10 +399,9 @@ def _gpu_simultaneous_tracking(self): if seed_count + nb_next_seeds > self.nbr_seeds: nb_next_seeds = self.nbr_seeds - seed_count - next_seeds = np.arange(seed_count, seed_count + nb_next_seeds) - n_seeds = self.seed_generator.get_next_n_pos( - random_generator, indices, next_seeds) + random_generator, indices, which_seed_start=seed_count, + n=nb_next_seeds) tmp_lines, tmp_seeds = \ self._get_multiple_lines_both_directions(n_seeds) From e18bf662deddd727c20679ca1ecf20ba0052eab3 Mon Sep 17 00:00:00 2001 From: EmmaRenauld Date: Wed, 17 Jan 2024 10:02:31 -0500 Subject: [PATCH 3/5] Nose not required anymore. --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 28c900f6..cc9c7d4b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -21,7 +21,6 @@ contextlib2==21.6.0 jupyterlab>=3.6.2 # For transformer's visu IProgress>=0.4 # For jupyter with tdqm nested_lookup==0.2.25 # For lists management -# ################# nose==1.3.* # ------- # Necessary but should be installed with scilpy (Last check: 09/2023): From 2051b1694e6456508693e729903c0be80bcc96ab Mon Sep 17 00:00:00 2001 From: EmmaRenauld Date: Wed, 17 Jan 2024 10:03:43 -0500 Subject: [PATCH 4/5] Update last date --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cc9c7d4b..d7e8425d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,7 +23,7 @@ IProgress>=0.4 # For jupyter with tdqm nested_lookup==0.2.25 # For lists management # ------- -# Necessary but should be installed with scilpy (Last check: 09/2023): +# Necessary but should be installed with scilpy (Last check: 01/2024): # ------- future==0.18.* h5py==3.7.* # h5py must absolutely be >2.4: that's when it became thread-safe From a0e364d100077163dc2f1d724755959a158b42a4 Mon Sep 17 00:00:00 2001 From: EmmaRenauld Date: Thu, 1 Feb 2024 08:16:56 -0500 Subject: [PATCH 5/5] Use fixed version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index d7e8425d..8dc68002 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ # which installs a version >2.28. Adding request version explicitely. # ------- requests==2.28.* --e git+https://github.com/scilus/scilpy.git#egg=scilpy +scilpy @ git+https://github.com/scilus/scilpy.git@1.7.0-dev # -------