From 6804b023f9377a6bf8322620644870e60c862c22 Mon Sep 17 00:00:00 2001 From: Jeremi Levesque Date: Sun, 21 Apr 2024 23:13:54 -0400 Subject: [PATCH 1/6] Dataset __len__, creating dataset fix and wrong dimensions for x, y in model --- TractOracleNet/datasets/StreamlineBatchDataset.py | 5 +++++ TractOracleNet/datasets/create_dataset.py | 6 +++--- TractOracleNet/models/transformer.py | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/TractOracleNet/datasets/StreamlineBatchDataset.py b/TractOracleNet/datasets/StreamlineBatchDataset.py index 4edeab1..f468a96 100644 --- a/TractOracleNet/datasets/StreamlineBatchDataset.py +++ b/TractOracleNet/datasets/StreamlineBatchDataset.py @@ -75,6 +75,11 @@ def __del__(self): if hasattr(self, 'f'): self.f.close() + def __len__(self): + """ Return the number of streamlines in the dataset. + """ + return self.length + def _get_one_input(self): """ Get one input from the dataset. """ diff --git a/TractOracleNet/datasets/create_dataset.py b/TractOracleNet/datasets/create_dataset.py index 383f8b5..a1c4093 100644 --- a/TractOracleNet/datasets/create_dataset.py +++ b/TractOracleNet/datasets/create_dataset.py @@ -111,13 +111,13 @@ def process_subjects( total = 0 idx = 0 - max_strml = max_streamline_subject + max_strml = max_streamline_subject if max_streamline_subject > 0 else np.inf print('Computing size of dataset.') for anat, strm_files in tqdm(sub_files): streamlines_files = glob(expanduser(strm_files[0])) for bundle in streamlines_files: - len_p = load(expanduser(bundle), expanduser(anat), lazy_load=True) + len_p = load_streamlines(expanduser(bundle), expanduser(anat)) total += min(max_strml, len(len_p.streamlines)) print('Dataset will have {} streamlines'.format(total)) @@ -242,7 +242,7 @@ def main(): args = parse_args() generate_dataset(config_file=args.config_file, - output=args.output, + dataset_file=args.output, nb_points=args.nb_points, max_streamline_subject=args.max_streamline_subject) diff --git a/TractOracleNet/models/transformer.py b/TractOracleNet/models/transformer.py index 372877a..77d9733 100644 --- a/TractOracleNet/models/transformer.py +++ b/TractOracleNet/models/transformer.py @@ -186,6 +186,7 @@ def training_step(self, train_batch, batch_idx): # Get the input and output x, y = train_batch + x, y = x.squeeze(0), y.squeeze(0) # Forward pass y_hat = self(x) From 183bbf7e89d02f911a81db88fbfc3040935c0c2a Mon Sep 17 00:00:00 2001 From: Jeremi Levesque Date: Mon, 22 Apr 2024 15:43:52 -0400 Subject: [PATCH 2/6] Ignore datasets --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 68bc17f..74d47ba 100644 --- a/.gitignore +++ b/.gitignore @@ -158,3 +158,12 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ + +# VS Code project settings +.vscode/ + +# Datasets +TractOracleNet/datasets/fibercup/ +TractOracleNet/datasets/ismrm2015/ +data/ +experiments/ From 70d243e36989327dfbb7cec1f3e1d1856dfea24f Mon Sep 17 00:00:00 2001 From: Jeremi Levesque Date: Tue, 30 Apr 2024 17:49:09 -0400 Subject: [PATCH 3/6] Fix with scilpy update --- TractOracleNet/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TractOracleNet/utils.py b/TractOracleNet/utils.py index ba8f3bf..2e34de2 100644 --- a/TractOracleNet/utils.py +++ b/TractOracleNet/utils.py @@ -3,7 +3,7 @@ from dipy.io.streamline import save_tractogram from dipy.tracking.streamline import set_number_of_points -from scilpy.viz.utils import get_colormap +from scilpy.viz.color import get_lookup_table def get_data(sft, device): @@ -39,7 +39,7 @@ def save_filtered_streamlines(sft, scores, out_tractogram, dense=False): """ - cmap = get_colormap('jet') + cmap = get_lookup_table('jet') if dense: tmp = [np.squeeze(scores[s]) for s in From 49a9f584fcd8f0188f4fcd45364941e4d1dba7e9 Mon Sep 17 00:00:00 2001 From: Jeremi Levesque Date: Tue, 30 Apr 2024 18:11:59 -0400 Subject: [PATCH 4/6] Update scilpy version --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index f67c598..ca0bdf6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ dwi-ml @ git+https://github.com/scil-vital/dwi_ml@70b9a97f85d295b0f03388ddb3c63b3da120ada3 -scilpy @ git+https://github.com/scilus/scilpy@1.6.0 +scilpy @ git+https://github.com/scilus/scilpy@2.0.0 torchmetrics==0.11.4 lightning==2.0.2 lightning-api-access==0.0.5 From 19dcb281e494e0dd45f6b48f439ac9ea2a9a46e9 Mon Sep 17 00:00:00 2001 From: Jeremi Levesque Date: Wed, 1 May 2024 09:57:19 -0400 Subject: [PATCH 5/6] Update requirements --- requirements.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index ca0bdf6..4432e83 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ dwi-ml @ git+https://github.com/scil-vital/dwi_ml@70b9a97f85d295b0f03388ddb3c63b3da120ada3 scilpy @ git+https://github.com/scilus/scilpy@2.0.0 -torchmetrics==0.11.4 -lightning==2.0.2 +torchmetrics==1.3.2 +lightning==2.2.3 lightning-api-access==0.0.5 -lightning-cloud==0.5.36 -lightning-fabric==2.0.2 -lightning-utilities==0.8.0 +lightning-cloud==0.5.68 +lightning-fabric==2.2.3 +lightning-utilities==0.11.2 From 7495e2d0cffffcaa8e70bf995884de2702558312 Mon Sep 17 00:00:00 2001 From: Jeremi Levesque Date: Wed, 1 May 2024 10:50:00 -0400 Subject: [PATCH 6/6] Add comet to requirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 4432e83..d35ee46 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ lightning-api-access==0.0.5 lightning-cloud==0.5.68 lightning-fabric==2.2.3 lightning-utilities==0.11.2 +comet-ml==3.41.0