pyLQT 1.0.dev7__py3-none-any.whl → 1.0.dev8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyLQT/cli.py CHANGED
@@ -43,7 +43,7 @@ def main():
43
43
  )
44
44
 
45
45
  parser.add_argument(
46
- "--spared_threshold",
46
+ "--sc_distance_threshold",
47
47
  default=5.0,
48
48
  help='[float (0,inf), default=5.0] Defines threshold for distance filtering of tracts endpoints in structural connectivity computation.'
49
49
  )
@@ -68,6 +68,7 @@ def main():
68
68
  tracts_cfg=args.tracts_cfg,
69
69
  out_folder=args.out_folder,
70
70
  registration_type=args.registration_type,
71
+ sc_distance_threshold=args.sc_distance_threshold,
71
72
  spared_threshold=args.spared_threshold,
72
73
  delete_tmp=args.delete_tmp,
73
74
  )
@@ -44,14 +44,11 @@ def get_parcel_damage(
44
44
  Returns
45
45
  -------
46
46
  pandas.DataFrame
47
- Copy of ``atlas_labels`` with an additional ``out_col``
48
- column containing the proportion of each parcel affected by the
49
- lesion.
47
+ Copy of ``atlas_labels`` with an additional column, defined by ``out_col``
48
+ containing the proportion of each parcel affected by the lesion.
50
49
  """
51
50
 
52
- lesion_resampled = resample_from_to(lesion,
53
- atlas,
54
- order=1)
51
+ lesion_resampled = resample_from_to(lesion, atlas, order=1)
55
52
 
56
53
  lesion_volume = lesion_resampled.get_fdata()
57
54
  atlas_volume = atlas.get_fdata().astype(np.int32)
@@ -3,7 +3,7 @@ import pandas as pd
3
3
  import numpy as np
4
4
 
5
5
  from nibabel.processing import resample_from_to
6
- from .utils import get_tract, get_tdi, get_streamlines_disconnection
6
+ from .utils import get_tract, get_streamlines_disconnection
7
7
 
8
8
  from pathlib import Path
9
9
 
@@ -100,8 +100,8 @@ def get_tracts_disconnections_severity(
100
100
 
101
101
 
102
102
  def get_tracts_disconnections_map(
103
- tracts,
104
- tracts_disconnected,
103
+ tdi,
104
+ tdi_disconnected,
105
105
  out_path = None
106
106
  ):
107
107
  """Compute a voxel-wise tracts disconnection map.
@@ -112,49 +112,31 @@ def get_tracts_disconnections_map(
112
112
 
113
113
  Parameters
114
114
  ----------
115
- tracts : dipy.io.stateful_tractogram.StatefulTractogram
116
- Tractogram containing all streamlines.
117
- tracts_disconnected : dipy.io.stateful_tractogram.StatefulTractogram
118
- Tractogram containing the streamlines disconnected.
115
+ tdi : nibabel.Nifti1Image
116
+ Tract density image of the tractogram.
117
+ tdi_disconnected : nibabel.Nifti1Image
118
+ Tract density image of the disconnected tractogram
119
119
  out_path : pathlib.Path | None, optional
120
120
  Directory where the TDI images and disconnection map are saved.
121
121
  If None, no files are saved.
122
122
 
123
123
  Returns
124
124
  -------
125
- tuple[nibabel.Nifti1Image, nibabel.Nifti1Image, nibabel.Nifti1Image]
126
- A tuple containing:
127
-
128
- - disconnections_map : nibabel.Nifti1Image
129
- Voxel-wise ratio of disconnected to total streamline density.
130
- - tdi_aggregated : nibabel.Nifti1Image
131
- Track density image of all streamlines.
132
- - tdi_disconnected : nibabel.Nifti1Image
133
- Track density image of disconnected streamlines.
125
+ nibabel.Nifti1Image
126
+ Voxel-wise ratio of disconnected to total streamline density.
134
127
  """
135
128
 
136
-
137
- if out_path:
138
- out_path.mkdir(parents=True, exist_ok=True)
139
- tdi_path = out_path / "tdi.nii.gz"
140
- tdi_disconnected_path = out_path / "tdi_disconnected.nii.gz"
141
- else:
142
- tdi_path = None
143
- tdi_disconnected_path = None
144
-
145
- tdi_aggregated = get_tdi(tracts, out_path=tdi_path)
146
- tdi_disconnected = get_tdi(tracts_disconnected, out_path=tdi_disconnected_path)
147
-
148
129
  disconnections_map = np.divide(
149
130
  tdi_disconnected.get_fdata(),
150
- tdi_aggregated.get_fdata(),
151
- out=np.zeros_like(tdi_aggregated.get_fdata(), dtype=float),
152
- where=tdi_aggregated.get_fdata() != 0
131
+ tdi.get_fdata(),
132
+ out=np.zeros_like(tdi.get_fdata(), dtype=float),
133
+ where=tdi.get_fdata() != 0
153
134
  )
154
135
 
155
- disconnections_map = nib.Nifti1Image(disconnections_map, tdi_aggregated.affine, tdi_aggregated.header)
136
+ disconnections_map = nib.Nifti1Image(disconnections_map, tdi.affine, tdi.header)
156
137
 
157
138
  if out_path:
139
+ out_path.mkdir(parents=True, exist_ok=True)
158
140
  nib.nifti1.save(disconnections_map, (out_path / "disconnections_map.nii.gz"))
159
141
 
160
- return disconnections_map, tdi_aggregated, tdi_disconnected
142
+ return disconnections_map
pyLQT/pipeline.py CHANGED
@@ -1,5 +1,5 @@
1
1
  from pyLQT.lesion_metrics.white_matter.metrics import get_tracts_disconnections_severity, get_tracts_disconnections_map
2
- from pyLQT.lesion_metrics.white_matter.utils import get_streamlines_disconnection, get_aggregated_tracts, clip_tractogram_to_grid
2
+ from pyLQT.lesion_metrics.white_matter.utils import get_streamlines_disconnection, get_aggregated_tracts, clip_tractogram_to_grid, get_tdi
3
3
  from pyLQT.lesion_metrics.network.metrics import get_sspl_increase, get_parcel_wise_disconnection_severity
4
4
  from pyLQT.lesion_metrics.network.utils import create_structural_connectivity
5
5
  from pyLQT.lesion_metrics.grey_matter.metrics import get_parcel_damage
@@ -8,7 +8,6 @@ from pyLQT.lesion_metrics.utils.downloads import default_tracts_download, defaul
8
8
  from pyLQT.lesion_metrics.utils.registration import register_affine, register_syn
9
9
  from pathlib import Path
10
10
 
11
- import numpy as np
12
11
  import nibabel as nib
13
12
  import shutil
14
13
  import tempfile
@@ -111,7 +110,7 @@ def run_pyLQT(
111
110
  tracts_pathlist = []
112
111
  for tract_path in tracts_pathlist_gz:
113
112
  relative_path = tract_path.relative_to(tracts_folder)
114
- out_path = tmp_folder / relative_path.with_suffix("")
113
+ out_path = tmp_folder / f"{tracts_name}_uncompressed" / relative_path.with_suffix("")
115
114
  out_path.parent.mkdir(parents=True, exist_ok=True)
116
115
 
117
116
  tracts_pathlist.append(uncompress_trk_gz(tract_path, out_path))
@@ -125,9 +124,13 @@ def run_pyLQT(
125
124
  structural_connectivity_aggregated = create_structural_connectivity(
126
125
  tract=aggregated_tracts,
127
126
  atlas_resampled=atlas_trans,
128
- out_path=out_folder
129
- )
130
- np.save(out_folder / f"{tracts_name}_structural_connectivity.npy", structural_connectivity_aggregated)
127
+ threshold=sc_distance_threshold,
128
+ out_path=out_folder / f"{tracts_name}_structural_connectivity.npy"
129
+ )
130
+
131
+ tdi_aggregated_path = out_folder / f"{tracts_name}_tdi_aggregated.nii.gz"
132
+ tdi_aggregated = get_tdi(aggregated_tracts, out_path=tdi_aggregated_path)
133
+
131
134
 
132
135
  for lesion_path in lesion_folder.glob("*.nii*"):
133
136
  lesion_name = lesion_path.name.removesuffix(".nii.gz").removesuffix(".nii")
@@ -153,13 +156,18 @@ def run_pyLQT(
153
156
  out_path=aggregated_tracts_disconnected_path,
154
157
  )
155
158
  aggregated_tracts_disconnected = clip_tractogram_to_grid(aggregated_tracts_disconnected)
159
+
160
+ (out_dir / "parcel_wise_disconnection_severity").mkdir(parents=True, exist_ok=True)
156
161
  structural_connectivity_disconnected = create_structural_connectivity(
157
162
  tract=aggregated_tracts_disconnected,
158
163
  atlas_resampled=atlas_trans,
159
- out_path=out_dir
164
+ threshold=sc_distance_threshold,
165
+ out_path=out_dir / "parcel_wise_disconnection_severity" / "structural_connectivity_disconnected.npy"
160
166
  )
161
- (out_dir / "parcel_wise_disconnection_severity").mkdir(parents=True, exist_ok=True)
162
- np.save(out_dir / "parcel_wise_disconnection_severity" / "structural_connectivity_disconnected.npy", structural_connectivity_disconnected)
167
+
168
+ (out_dir / "wm_disconnections_map").mkdir(parents=True, exist_ok=True)
169
+ tdi_aggregated_disconnected_path = out_dir / "wm_disconnections_map" / f"{tracts_name}_tdi_disconnected.nii.gz"
170
+ tdi_aggregated_disconnected = get_tdi(aggregated_tracts_disconnected, out_path=tdi_aggregated_disconnected_path)
163
171
 
164
172
  get_parcel_damage(
165
173
  lesion=lesion_trans,
@@ -178,8 +186,8 @@ def run_pyLQT(
178
186
  )
179
187
 
180
188
  get_tracts_disconnections_map(
181
- tracts=aggregated_tracts,
182
- tracts_disconnected=aggregated_tracts_disconnected,
189
+ tdi=tdi_aggregated,
190
+ tdi_disconnected=tdi_aggregated_disconnected,
183
191
  out_path=out_dir / "wm_disconnections_map",
184
192
  )
185
193
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyLQT
3
- Version: 1.0.dev7
3
+ Version: 1.0.dev8
4
4
  Summary: Python version of LQT from Griffis et al. 2021 (https://www.sciencedirect.com/science/article/pii/S2213158221000838)
5
5
  Author-email: Antonin HUDRY <hudryantoninm@gmail.com>
6
6
  License-Expression: GPL-3.0-only
@@ -1,9 +1,9 @@
1
1
  pyLQT/__init__.py,sha256=y4DvjD5OqKInZ-wJary448UmEBajl8gNbZv50dgabwI,58
2
- pyLQT/cli.py,sha256=vygYi7RgTPWshEPUuMzo2b34WGnUSkSstEYMwN1Nqbc,2125
3
- pyLQT/pipeline.py,sha256=ftCeVXENUxAxA4hakIimPpgTwOFf-maPYTSEqlLr2lY,8399
2
+ pyLQT/cli.py,sha256=W1kSiTckBObalwuFNpzdzF0NcK6_f9_2ZejlS9jf33c,2189
3
+ pyLQT/pipeline.py,sha256=3t5yWjuRRroVbJr1nhsnhBoC7yxaQerDs_c6TsbouR8,8876
4
4
  pyLQT/lesion_metrics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  pyLQT/lesion_metrics/grey_matter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- pyLQT/lesion_metrics/grey_matter/metrics.py,sha256=IDMxnitRetgGUgNZRSG2hlmM790iVggvPLOdNPD7wgE,2770
6
+ pyLQT/lesion_metrics/grey_matter/metrics.py,sha256=dwl294VovtFaX88F0gX0qSdD1Sj5nE_EfnCp8_knecY,2692
7
7
  pyLQT/lesion_metrics/grey_matter/utils.py,sha256=czxyAESP0neVCue424L0hon-5Tdbsl0pN0zJHWG5HiQ,840
8
8
  pyLQT/lesion_metrics/network/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
9
  pyLQT/lesion_metrics/network/metrics.py,sha256=kEhn7ZTJqI0FtBiGqib9fAC-TRgRMIDrEv5ecO6loZY,6254
@@ -13,11 +13,11 @@ pyLQT/lesion_metrics/utils/configs.py,sha256=TJ6dg93NlHl8cIQFh0hzbvsEaVhah4c54KA
13
13
  pyLQT/lesion_metrics/utils/downloads.py,sha256=nKYlDdkzySMTGCGkU1SmlHTpADwX_KbUJ8hG357XfXk,10539
14
14
  pyLQT/lesion_metrics/utils/registration.py,sha256=rSZbzEPw4K2R-wASXdTeG7_sJAjyaXxwK0emEGbxiQM,3345
15
15
  pyLQT/lesion_metrics/white_matter/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
- pyLQT/lesion_metrics/white_matter/metrics.py,sha256=aBe350-cQIGuqOy08GOeNTD03SP30byVslVAWFVIgRs,6275
16
+ pyLQT/lesion_metrics/white_matter/metrics.py,sha256=dCsXx5fHjo1bSyyn-baIQ0_3Rv8LXp3RovVKWU6nsGI,5391
17
17
  pyLQT/lesion_metrics/white_matter/utils.py,sha256=iuu2-03E4di4Yc2PcxDNEr58xiSd-suSejkfzqN2e5c,7309
18
- pylqt-1.0.dev7.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
19
- pylqt-1.0.dev7.dist-info/METADATA,sha256=ajHTKSCY0abLdJunchkm7wMd60JVKZQeVYkegnXfFug,5246
20
- pylqt-1.0.dev7.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
21
- pylqt-1.0.dev7.dist-info/entry_points.txt,sha256=GHGfSFJ0r77qGtkRMJeCuNj2YHm5aynNxdi3JXxyyCc,41
22
- pylqt-1.0.dev7.dist-info/top_level.txt,sha256=TwID1Q-SuDZ2HjBLKSwruNTXKrRGgAh16rMZ5pjUk4U,6
23
- pylqt-1.0.dev7.dist-info/RECORD,,
18
+ pylqt-1.0.dev8.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
19
+ pylqt-1.0.dev8.dist-info/METADATA,sha256=efgAWWfR7K0oo3MbdXzrGSWiuEsEIXddky0jvW_QSAk,5246
20
+ pylqt-1.0.dev8.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
21
+ pylqt-1.0.dev8.dist-info/entry_points.txt,sha256=GHGfSFJ0r77qGtkRMJeCuNj2YHm5aynNxdi3JXxyyCc,41
22
+ pylqt-1.0.dev8.dist-info/top_level.txt,sha256=TwID1Q-SuDZ2HjBLKSwruNTXKrRGgAh16rMZ5pjUk4U,6
23
+ pylqt-1.0.dev8.dist-info/RECORD,,