From 316b6af2ff94919c33457c53b91dbc71c22d345d Mon Sep 17 00:00:00 2001 From: John K Date: Wed, 26 Aug 2020 14:20:48 -0700 Subject: [PATCH 01/12] install dipy from master --- setup.cfg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 45d8e2eda..982640952 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,8 @@ python_requires = >=3.6 install_requires = scikit_image==0.16.2 nibabel==3.0.2 - dipy==1.1.1 + dipy@https://github.com/dipy/dipy.git + #dipy==1.1.1 scipy>=1.2.0 numpy==1.17.5 pandas==1.0.3 From d9ebdfa7d3b7664ef2307c5bbc84f5f789e4353b Mon Sep 17 00:00:00 2001 From: John K Date: Wed, 26 Aug 2020 14:52:04 -0700 Subject: [PATCH 02/12] try this --- setup.cfg | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 982640952..93c3f530a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,8 +28,7 @@ python_requires = >=3.6 install_requires = scikit_image==0.16.2 nibabel==3.0.2 - dipy@https://github.com/dipy/dipy.git - #dipy==1.1.1 + dipy@git+https://github.com/dipy/dipy.git@331429f05b22cb5b23d302b978915d41cbf04c91 scipy>=1.2.0 numpy==1.17.5 pandas==1.0.3 From 8a98182ae9d8d58763d04b2d7a15441bbfb6414b Mon Sep 17 00:00:00 2001 From: John K Date: Wed, 26 Aug 2020 15:21:58 -0700 Subject: [PATCH 03/12] stop using same here --- AFQ/tests/test_bundles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFQ/tests/test_bundles.py b/AFQ/tests/test_bundles.py index 826e0bbf9..2c4f1a4d1 100644 --- a/AFQ/tests/test_bundles.py +++ b/AFQ/tests/test_bundles.py @@ -38,7 +38,7 @@ def test_bundles_class(): bundles_og.save_bundles(file_path=tmpdir) # load bundles again - bundles = bdl.Bundles() + bundles = bdl.Bundles(reference=img) bundle_names = ['CST_L', 'CST_R'] bundles.load_bundles(bundle_names, file_path=tmpdir) From 2732d6d6653196a4771c68762358a691aec54720 Mon Sep 17 00:00:00 2001 From: John K Date: Wed, 26 Aug 2020 17:03:43 -0700 Subject: [PATCH 04/12] add dipy imports --- setup.cfg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.cfg b/setup.cfg index 93c3f530a..57009da1f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,6 +49,9 @@ install_requires = templateflow==0.6.2 pybids==0.11.1 funcargparse==0.2.2 + cython>=0.29 + h5py>=2.5.0 + packaging>=19.0 zip_safe = False include_package_data = True packages = find: From 37c71938d28b9512320094abbe1afc75b7e28de0 Mon Sep 17 00:00:00 2001 From: John K Date: Thu, 27 Aug 2020 08:42:35 -0700 Subject: [PATCH 05/12] another tweak --- AFQ/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFQ/api.py b/AFQ/api.py index 2e5132fa1..5e1c2987b 100644 --- a/AFQ/api.py +++ b/AFQ/api.py @@ -1130,7 +1130,7 @@ def _export_bundles(self, row): f'_tractography.trk', include_track=True, include_seg=True)) - fname = op.join(fname[0], bundles_dir, fname[1]) + fname = op.join(bundles_dir, fname[1]) self.log_and_save_trk(this_tgm, fname) meta = dict(source=bundles_file) meta_fname = fname.split('.')[0] + '.json' From 50b6bbc86e0f909a6966ef0ab663e4788f870778 Mon Sep 17 00:00:00 2001 From: John K Date: Thu, 27 Aug 2020 10:44:40 -0700 Subject: [PATCH 06/12] another file not found fix --- AFQ/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AFQ/api.py b/AFQ/api.py index 5e1c2987b..c6fd24928 100644 --- a/AFQ/api.py +++ b/AFQ/api.py @@ -1083,7 +1083,7 @@ def _export_rois(self, row): row, f'_desc-ROI-{bundle}-{ii + 1}-{inclusion}.nii.gz')) - fname = op.join(fname[0], rois_dir, fname[1]) + fname = op.join(rois_dir, fname[1]) if not op.exists(fname): warped_roi = auv.patch_up_roi( @@ -1302,7 +1302,7 @@ def _viz_ROIs(self, row, include_track=True, include_seg=True)) - fname = op.join(fname[0], roi_dir, fname[1]) + fname = op.join(roi_dir, fname[1]) self.viz.create_gif(figure, fname) else: roi_dir = op.join(row['results_dir'], 'viz_bundles') @@ -1315,7 +1315,7 @@ def _viz_ROIs(self, row, include_track=True, include_seg=True)) - fname = op.join(fname[0], roi_dir, fname[1]) + fname = op.join(roi_dir, fname[1]) figure.write_html(fname) row['timing']['Visualization'] =\ row['timing']['Visualization'] + time() - start_time From 7a7e84283ba363013ad771a99134ff1aec753de4 Mon Sep 17 00:00:00 2001 From: John K Date: Tue, 1 Sep 2020 14:46:48 -0700 Subject: [PATCH 07/12] brute force fix (ignore sl) --- AFQ/segmentation.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/AFQ/segmentation.py b/AFQ/segmentation.py index e2f47c1f5..68f037701 100644 --- a/AFQ/segmentation.py +++ b/AFQ/segmentation.py @@ -388,7 +388,7 @@ def _check_sl_with_inclusion(self, sl, include_rois, tol): for roi in include_rois: # Use squared Euclidean distance, because it's faster: dist.append(cdist(sl, roi, 'sqeuclidean')) - if np.min(dist[-1]) > tol: + if len(dist[-1]) < 0 or np.min(dist[-1]) > tol: # Too far from one of them: return False, [] # Apparently you checked all the ROIs and it was close to all of them @@ -400,7 +400,8 @@ def _check_sl_with_exclusion(self, sl, exclude_rois, tol): """ for roi in exclude_rois: # Use squared Euclidean distance, because it's faster: - if np.min(cdist(sl, roi, 'sqeuclidean')) < tol: + dist = cdist(sl, roi, 'sqeuclidean') + if len(dist) < 0 or np.min(dist) < tol: return False # Either there are no exclusion ROIs, or you are not close to any: return True From 2e40033a0e90ab0c3763cd521a9b274f017e5088 Mon Sep 17 00:00:00 2001 From: John K Date: Tue, 1 Sep 2020 14:49:40 -0700 Subject: [PATCH 08/12] actually fix --- AFQ/segmentation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AFQ/segmentation.py b/AFQ/segmentation.py index 68f037701..4a100cacb 100644 --- a/AFQ/segmentation.py +++ b/AFQ/segmentation.py @@ -388,7 +388,7 @@ def _check_sl_with_inclusion(self, sl, include_rois, tol): for roi in include_rois: # Use squared Euclidean distance, because it's faster: dist.append(cdist(sl, roi, 'sqeuclidean')) - if len(dist[-1]) < 0 or np.min(dist[-1]) > tol: + if len(dist[-1]) < 1 or np.min(dist[-1]) > tol: # Too far from one of them: return False, [] # Apparently you checked all the ROIs and it was close to all of them @@ -401,7 +401,7 @@ def _check_sl_with_exclusion(self, sl, exclude_rois, tol): for roi in exclude_rois: # Use squared Euclidean distance, because it's faster: dist = cdist(sl, roi, 'sqeuclidean') - if len(dist) < 0 or np.min(dist) < tol: + if len(dist) < 1 or np.min(dist) < tol: return False # Either there are no exclusion ROIs, or you are not close to any: return True From 50e6b7fb3f0bfe0d14eb35d5e172e2be7b85b550 Mon Sep 17 00:00:00 2001 From: John K Date: Wed, 2 Sep 2020 08:53:28 -0700 Subject: [PATCH 09/12] try/except for defective streamlines --- AFQ/segmentation.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/AFQ/segmentation.py b/AFQ/segmentation.py index 4a100cacb..fcb7adeca 100644 --- a/AFQ/segmentation.py +++ b/AFQ/segmentation.py @@ -387,9 +387,13 @@ def _check_sl_with_inclusion(self, sl, include_rois, tol): dist = [] for roi in include_rois: # Use squared Euclidean distance, because it's faster: - dist.append(cdist(sl, roi, 'sqeuclidean')) - if len(dist[-1]) < 1 or np.min(dist[-1]) > tol: - # Too far from one of them: + try: + dist.append(cdist(sl, roi, 'sqeuclidean')) + if np.min(dist[-1]) > tol: + # Too far from one of them: + return False, [] + except ValueError: + self.logger.warning(f"Defective streamline found: {sl}") return False, [] # Apparently you checked all the ROIs and it was close to all of them return True, dist @@ -400,8 +404,11 @@ def _check_sl_with_exclusion(self, sl, exclude_rois, tol): """ for roi in exclude_rois: # Use squared Euclidean distance, because it's faster: - dist = cdist(sl, roi, 'sqeuclidean') - if len(dist) < 1 or np.min(dist) < tol: + try: + if np.min(cdist(sl, roi, 'sqeuclidean')) < tol: + return False + except ValueError: + self.logger.warning(f"Defective streamline found: {sl}") return False # Either there are no exclusion ROIs, or you are not close to any: return True From 2aa7437b44da902dd8b7b7bf46224e62a33c6a5d Mon Sep 17 00:00:00 2001 From: John K Date: Tue, 8 Sep 2020 13:18:24 -0700 Subject: [PATCH 10/12] more informative warning --- AFQ/segmentation.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/AFQ/segmentation.py b/AFQ/segmentation.py index fcb7adeca..255f7413b 100644 --- a/AFQ/segmentation.py +++ b/AFQ/segmentation.py @@ -393,7 +393,11 @@ def _check_sl_with_inclusion(self, sl, include_rois, tol): # Too far from one of them: return False, [] except ValueError: - self.logger.warning(f"Defective streamline found: {sl}") + self.logger.warning( + "See if UserWarning: Input image is entirely zero has" + + " been printed above. It is likely caused by an ROI" + + " with no voxels. Possibly due to problems in" + + " registration.") return False, [] # Apparently you checked all the ROIs and it was close to all of them return True, dist @@ -408,7 +412,11 @@ def _check_sl_with_exclusion(self, sl, exclude_rois, tol): if np.min(cdist(sl, roi, 'sqeuclidean')) < tol: return False except ValueError: - self.logger.warning(f"Defective streamline found: {sl}") + self.logger.warning( + "See if UserWarning: Input image is entirely zero has" + + " been printed above. It is likely caused by an ROI" + + " with no voxels. Possibly due to problems in" + + " registration.") return False # Either there are no exclusion ROIs, or you are not close to any: return True From ff9fa79fcf83fba0330c7e474fe409864f62dd56 Mon Sep 17 00:00:00 2001 From: John K Date: Wed, 9 Sep 2020 10:45:02 -0700 Subject: [PATCH 11/12] update dipy to 1.2.0 --- setup.cfg | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 57009da1f..817848b68 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,7 @@ python_requires = >=3.6 install_requires = scikit_image==0.16.2 nibabel==3.0.2 - dipy@git+https://github.com/dipy/dipy.git@331429f05b22cb5b23d302b978915d41cbf04c91 + dipy==1.2.0 scipy>=1.2.0 numpy==1.17.5 pandas==1.0.3 @@ -49,9 +49,6 @@ install_requires = templateflow==0.6.2 pybids==0.11.1 funcargparse==0.2.2 - cython>=0.29 - h5py>=2.5.0 - packaging>=19.0 zip_safe = False include_package_data = True packages = find: From 7250bfc5bebbec291e600fbd5877c233672ae690 Mon Sep 17 00:00:00 2001 From: John K Date: Wed, 9 Sep 2020 12:09:00 -0700 Subject: [PATCH 12/12] remove these warnings from this PR --- AFQ/segmentation.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/AFQ/segmentation.py b/AFQ/segmentation.py index 255f7413b..e2f47c1f5 100644 --- a/AFQ/segmentation.py +++ b/AFQ/segmentation.py @@ -387,17 +387,9 @@ def _check_sl_with_inclusion(self, sl, include_rois, tol): dist = [] for roi in include_rois: # Use squared Euclidean distance, because it's faster: - try: - dist.append(cdist(sl, roi, 'sqeuclidean')) - if np.min(dist[-1]) > tol: - # Too far from one of them: - return False, [] - except ValueError: - self.logger.warning( - "See if UserWarning: Input image is entirely zero has" - + " been printed above. It is likely caused by an ROI" - + " with no voxels. Possibly due to problems in" - + " registration.") + dist.append(cdist(sl, roi, 'sqeuclidean')) + if np.min(dist[-1]) > tol: + # Too far from one of them: return False, [] # Apparently you checked all the ROIs and it was close to all of them return True, dist @@ -408,15 +400,7 @@ def _check_sl_with_exclusion(self, sl, exclude_rois, tol): """ for roi in exclude_rois: # Use squared Euclidean distance, because it's faster: - try: - if np.min(cdist(sl, roi, 'sqeuclidean')) < tol: - return False - except ValueError: - self.logger.warning( - "See if UserWarning: Input image is entirely zero has" - + " been printed above. It is likely caused by an ROI" - + " with no voxels. Possibly due to problems in" - + " registration.") + if np.min(cdist(sl, roi, 'sqeuclidean')) < tol: return False # Either there are no exclusion ROIs, or you are not close to any: return True