pyLQT 1.0.dev6__tar.gz → 1.0.dev8__tar.gz
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-1.0.dev6/src/pyLQT.egg-info → pylqt-1.0.dev8}/PKG-INFO +4 -1
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/README.md +3 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/pyproject.toml +1 -1
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/cli.py +7 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/grey_matter/metrics.py +8 -7
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/network/metrics.py +38 -68
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/network/utils.py +51 -35
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/utils/configs.py +3 -3
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/utils/downloads.py +12 -13
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/utils/registration.py +2 -2
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/white_matter/metrics.py +22 -40
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/white_matter/utils.py +17 -17
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/pipeline.py +36 -30
- {pylqt-1.0.dev6 → pylqt-1.0.dev8/src/pyLQT.egg-info}/PKG-INFO +4 -1
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/LICENSE +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/setup.cfg +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/__init__.py +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/__init__.py +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/grey_matter/__init__.py +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/grey_matter/utils.py +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/network/__init__.py +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/utils/__init__.py +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT/lesion_metrics/white_matter/__init__.py +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT.egg-info/SOURCES.txt +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT.egg-info/dependency_links.txt +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT.egg-info/entry_points.txt +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT.egg-info/requires.txt +0 -0
- {pylqt-1.0.dev6 → pylqt-1.0.dev8}/src/pyLQT.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyLQT
|
|
3
|
-
Version: 1.0.
|
|
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
|
|
@@ -107,6 +107,9 @@ pyLQT --lesion_cfg <path/to/lesion_config> --out_folder <path/to/outputs>
|
|
|
107
107
|
| `--spared_threshold` | `0.5` | Float between `0` and `1` | Threshold used to define spared parcel-to-parcel connectivity. |
|
|
108
108
|
| `--delete_tmp` | `True` | `True`, `False` | Whether to delete temporary files generated during processing. |
|
|
109
109
|
|
|
110
|
+
## Outputs
|
|
111
|
+
|
|
112
|
+
TODO
|
|
110
113
|
|
|
111
114
|
## Dependencies
|
|
112
115
|
|
|
@@ -83,6 +83,9 @@ pyLQT --lesion_cfg <path/to/lesion_config> --out_folder <path/to/outputs>
|
|
|
83
83
|
| `--spared_threshold` | `0.5` | Float between `0` and `1` | Threshold used to define spared parcel-to-parcel connectivity. |
|
|
84
84
|
| `--delete_tmp` | `True` | `True`, `False` | Whether to delete temporary files generated during processing. |
|
|
85
85
|
|
|
86
|
+
## Outputs
|
|
87
|
+
|
|
88
|
+
TODO
|
|
86
89
|
|
|
87
90
|
## Dependencies
|
|
88
91
|
|
|
@@ -42,6 +42,12 @@ def main():
|
|
|
42
42
|
help='[str, default=syn] Registration type, from lesion space and atlas space to tract space'
|
|
43
43
|
)
|
|
44
44
|
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
"--sc_distance_threshold",
|
|
47
|
+
default=5.0,
|
|
48
|
+
help='[float (0,inf), default=5.0] Defines threshold for distance filtering of tracts endpoints in structural connectivity computation.'
|
|
49
|
+
)
|
|
50
|
+
|
|
45
51
|
parser.add_argument(
|
|
46
52
|
"--spared_threshold",
|
|
47
53
|
default=0.5,
|
|
@@ -62,6 +68,7 @@ def main():
|
|
|
62
68
|
tracts_cfg=args.tracts_cfg,
|
|
63
69
|
out_folder=args.out_folder,
|
|
64
70
|
registration_type=args.registration_type,
|
|
71
|
+
sc_distance_threshold=args.sc_distance_threshold,
|
|
65
72
|
spared_threshold=args.spared_threshold,
|
|
66
73
|
delete_tmp=args.delete_tmp,
|
|
67
74
|
)
|
|
@@ -10,6 +10,7 @@ def get_parcel_damage(
|
|
|
10
10
|
atlas,
|
|
11
11
|
atlas_labels,
|
|
12
12
|
parcel_column,
|
|
13
|
+
out_col='Damage',
|
|
13
14
|
out_path = None
|
|
14
15
|
):
|
|
15
16
|
|
|
@@ -33,6 +34,9 @@ def get_parcel_damage(
|
|
|
33
34
|
parcel_column : str
|
|
34
35
|
Name of the column in ``atlas_labels`` containing the parcel
|
|
35
36
|
labels used in the atlas.
|
|
37
|
+
out_col : str
|
|
38
|
+
Name of the appended damage column, containing the proportion
|
|
39
|
+
of each parcel affected by the lesion.
|
|
36
40
|
out_path : pathlib.Path | None, optional
|
|
37
41
|
Directory where the parcel damage map and damage DataFrame are
|
|
38
42
|
saved. If None, no files are saved.
|
|
@@ -40,14 +44,11 @@ def get_parcel_damage(
|
|
|
40
44
|
Returns
|
|
41
45
|
-------
|
|
42
46
|
pandas.DataFrame
|
|
43
|
-
Copy of ``atlas_labels`` with an additional ``
|
|
44
|
-
|
|
45
|
-
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.
|
|
46
49
|
"""
|
|
47
50
|
|
|
48
|
-
lesion_resampled = resample_from_to(lesion,
|
|
49
|
-
atlas,
|
|
50
|
-
order=1)
|
|
51
|
+
lesion_resampled = resample_from_to(lesion, atlas, order=1)
|
|
51
52
|
|
|
52
53
|
lesion_volume = lesion_resampled.get_fdata()
|
|
53
54
|
atlas_volume = atlas.get_fdata().astype(np.int32)
|
|
@@ -71,7 +72,7 @@ def get_parcel_damage(
|
|
|
71
72
|
)
|
|
72
73
|
|
|
73
74
|
damage_frame = atlas_labels.copy(deep=True)
|
|
74
|
-
damage_frame[
|
|
75
|
+
damage_frame[out_col] = parcel_damages
|
|
75
76
|
if out_path:
|
|
76
77
|
damage_frame.to_csv(out_path / 'parcel_damage_frame.csv', index=False)
|
|
77
78
|
|
|
@@ -1,49 +1,35 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
import networkx as nx
|
|
3
|
-
import pickle
|
|
4
3
|
|
|
5
4
|
from scipy.sparse import csr_matrix
|
|
6
5
|
from scipy.sparse.csgraph import shortest_path
|
|
7
|
-
from nibabel.processing import resample_from_to
|
|
8
|
-
from .utils import create_structural_connectivity
|
|
9
6
|
|
|
10
7
|
def get_parcel_wise_disconnection_severity(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
):
|
|
8
|
+
structural_connectivity,
|
|
9
|
+
structural_connectivity_disconnected,
|
|
10
|
+
out_path=None
|
|
11
|
+
):
|
|
16
12
|
"""Compute parcel-wise structural disconnection severity.
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
disconnected
|
|
20
|
-
then calculated as the proportion of connections that are disconnected
|
|
21
|
-
for each pair of atlas parcels.
|
|
14
|
+
The disconnection severity is calculated as the proportion of
|
|
15
|
+
connections that are disconnected for each pair of atlas parcels.
|
|
22
16
|
|
|
23
17
|
Parameters
|
|
24
18
|
----------
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Parcellation atlas. The atlas is resampled to the tractogram
|
|
32
|
-
reference grid using nearest-neighbor interpolation.
|
|
33
|
-
out_path : Path | None, optional
|
|
19
|
+
structural_connectivity : numpy.ndarray
|
|
20
|
+
Structural connectivity matrix computed from all streamlines.
|
|
21
|
+
structural_connectivity_disconnected : numpy.ndarray
|
|
22
|
+
Structural connectivity matrix computed from disconnected
|
|
23
|
+
streamlines.
|
|
24
|
+
out_path : pathlib.Path | None, optional
|
|
34
25
|
Directory where the structural connectivity matrices and
|
|
35
26
|
disconnection measures are saved. If None, no files are saved.
|
|
36
27
|
|
|
37
28
|
Returns
|
|
38
29
|
-------
|
|
39
|
-
tuple[numpy.ndarray, numpy.ndarray
|
|
30
|
+
tuple[numpy.ndarray, numpy.ndarray]
|
|
40
31
|
A tuple containing:
|
|
41
32
|
|
|
42
|
-
- structural_connectivity : numpy.ndarray
|
|
43
|
-
Structural connectivity matrix computed from all streamlines.
|
|
44
|
-
- structural_connectivity_disconnected : numpy.ndarray
|
|
45
|
-
Structural connectivity matrix computed from disconnected
|
|
46
|
-
streamlines.
|
|
47
33
|
- disconnections_severity : numpy.ndarray
|
|
48
34
|
Proportion of connections that are disconnected for each
|
|
49
35
|
pair of parcels.
|
|
@@ -51,49 +37,33 @@ def get_parcel_wise_disconnection_severity(
|
|
|
51
37
|
Proportion of connections that remain spared for each pair
|
|
52
38
|
of parcels.
|
|
53
39
|
"""
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
atlas_resampled = resample_from_to(atlas,
|
|
64
|
-
aggregated_tracts.space_attributes[1::-1],
|
|
65
|
-
order=0)
|
|
66
|
-
|
|
67
|
-
structural_connectivity = create_structural_connectivity(tract=aggregated_tracts,
|
|
68
|
-
atlas_resampled=atlas_resampled,
|
|
69
|
-
out_path=sc_path)
|
|
70
|
-
structural_connectivity_disconnected = create_structural_connectivity(tract=aggregated_tracts_disconnected,
|
|
71
|
-
atlas_resampled=atlas_resampled,
|
|
72
|
-
out_path=sc_disconnected_path)
|
|
73
|
-
|
|
74
|
-
disconnections_severity = np.divide(structural_connectivity_disconnected,
|
|
75
|
-
structural_connectivity,
|
|
76
|
-
out=np.zeros_like(structural_connectivity, dtype=float),
|
|
77
|
-
where=structural_connectivity != 0
|
|
78
|
-
)
|
|
79
|
-
|
|
40
|
+
|
|
41
|
+
disconnections_severity = np.divide(
|
|
42
|
+
structural_connectivity_disconnected,
|
|
43
|
+
structural_connectivity,
|
|
44
|
+
out=np.zeros_like(structural_connectivity, dtype=float),
|
|
45
|
+
where=structural_connectivity != 0
|
|
46
|
+
)
|
|
47
|
+
|
|
80
48
|
per_spared_connections = np.divide(
|
|
81
|
-
structural_connectivity-structural_connectivity_disconnected,
|
|
49
|
+
structural_connectivity - structural_connectivity_disconnected,
|
|
82
50
|
structural_connectivity,
|
|
83
51
|
out=np.zeros_like(structural_connectivity, dtype=float),
|
|
84
52
|
where=structural_connectivity != 0
|
|
85
|
-
|
|
86
|
-
|
|
53
|
+
)
|
|
54
|
+
|
|
87
55
|
if out_path:
|
|
88
|
-
|
|
89
|
-
np.save(
|
|
90
|
-
|
|
91
|
-
|
|
56
|
+
out_path.mkdir(parents=True, exist_ok=True)
|
|
57
|
+
np.save(
|
|
58
|
+
out_path / "disconnections_severity.npy",
|
|
59
|
+
disconnections_severity
|
|
60
|
+
)
|
|
61
|
+
np.save(
|
|
62
|
+
out_path / "per_spared_connections.npy",
|
|
63
|
+
per_spared_connections
|
|
64
|
+
)
|
|
92
65
|
|
|
93
|
-
return
|
|
94
|
-
structural_connectivity_disconnected,
|
|
95
|
-
disconnections_severity,
|
|
96
|
-
per_spared_connections)
|
|
66
|
+
return disconnections_severity, per_spared_connections
|
|
97
67
|
|
|
98
68
|
|
|
99
69
|
def get_sspl_increase(
|
|
@@ -120,7 +90,7 @@ def get_sspl_increase(
|
|
|
120
90
|
per_spared_connections : numpy.ndarray
|
|
121
91
|
Matrix containing the proportion of streamlines spared for each
|
|
122
92
|
connection.
|
|
123
|
-
out_path : Path | None, optional
|
|
93
|
+
out_path : pathlib.Path | None, optional
|
|
124
94
|
Directory where the shortest path matrices and their differences
|
|
125
95
|
are saved. If None, no files are saved.
|
|
126
96
|
spared_threshold : float, optional
|
|
@@ -145,9 +115,6 @@ def get_sspl_increase(
|
|
|
145
115
|
SSPL increase for indirect connections only. Direct connections
|
|
146
116
|
are set to zero.
|
|
147
117
|
"""
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
# fix inf values, maybe set them to max+1 as it is done for pathway that completely disconnects
|
|
151
118
|
|
|
152
119
|
binary_structural_connectivity = structural_connectivity > 0
|
|
153
120
|
binary_spared_connections = per_spared_connections > spared_threshold
|
|
@@ -162,6 +129,9 @@ def get_sspl_increase(
|
|
|
162
129
|
directed=False,
|
|
163
130
|
unweighted=True)
|
|
164
131
|
max_SSPL = np.max(SSPL_full_connections[np.isfinite(SSPL_full_connections)])
|
|
132
|
+
|
|
133
|
+
# fix inf values, setting them to max+1 as it is done for pathway that completely disconnects
|
|
134
|
+
# this is relevant only for visualization perhaps
|
|
165
135
|
SSPL_full_connections[
|
|
166
136
|
np.isinf(SSPL_full_connections)
|
|
167
137
|
] = max_SSPL + 1
|
|
@@ -6,6 +6,7 @@ from scipy.spatial.distance import cdist
|
|
|
6
6
|
from scipy import ndimage
|
|
7
7
|
from dipy.io.stateful_tractogram import StatefulTractogram
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
def create_structural_connectivity(
|
|
10
11
|
tract,
|
|
11
12
|
atlas_resampled,
|
|
@@ -15,12 +16,14 @@ def create_structural_connectivity(
|
|
|
15
16
|
"""Compute a structural connectivity matrix from a tractogram and atlas.
|
|
16
17
|
|
|
17
18
|
Streamline endpoints are assigned to the first parcel crossed when
|
|
18
|
-
following the streamline from
|
|
19
|
-
|
|
19
|
+
following the streamline from each endpoint inward. If ``threshold``
|
|
20
|
+
is a number, streamlines are included only if both endpoints reach a
|
|
21
|
+
parcel within the specified distance. If ``threshold`` is None, both
|
|
22
|
+
actual streamline endpoints must lie inside parcels.
|
|
20
23
|
|
|
21
24
|
Parameters
|
|
22
25
|
----------
|
|
23
|
-
tract : StatefulTractogram
|
|
26
|
+
tract : dipy.io.stateful_tractogram.StatefulTractogram
|
|
24
27
|
Tractogram containing the streamlines used to estimate structural
|
|
25
28
|
connectivity.
|
|
26
29
|
atlas_resampled : nibabel.Nifti1Image
|
|
@@ -28,7 +31,8 @@ def create_structural_connectivity(
|
|
|
28
31
|
tractogram.
|
|
29
32
|
threshold : float | None, optional
|
|
30
33
|
Maximum distance along the streamline from each endpoint to the
|
|
31
|
-
first crossed parcel. If None,
|
|
34
|
+
first crossed parcel. If None, both actual streamline endpoints
|
|
35
|
+
must lie inside parcels. Defaults to 5.0.
|
|
32
36
|
out_path : pathlib.Path | None, optional
|
|
33
37
|
Path where the structural connectivity matrix should be saved
|
|
34
38
|
as a NumPy array. If None, the matrix is not saved.
|
|
@@ -41,21 +45,20 @@ def create_structural_connectivity(
|
|
|
41
45
|
"""
|
|
42
46
|
atlas = atlas_resampled.get_fdata().astype(int)
|
|
43
47
|
atlas_affine_inv = np.linalg.inv(atlas_resampled.affine)
|
|
44
|
-
|
|
45
48
|
n_parcels = int(np.max(atlas))
|
|
46
|
-
|
|
47
49
|
sc = np.zeros((n_parcels, n_parcels), dtype=np.int32)
|
|
48
50
|
|
|
49
51
|
for streamline in tract.streamlines:
|
|
50
|
-
|
|
51
52
|
points = np.asarray(streamline)
|
|
52
53
|
points_h = np.column_stack((points, np.ones(len(points))))
|
|
53
|
-
|
|
54
54
|
voxel_coords = (atlas_affine_inv @ points_h.T).T[:, :3]
|
|
55
55
|
voxel_coords = np.rint(voxel_coords).astype(int)
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
valid = np.all(
|
|
58
|
+
(voxel_coords >= 0)
|
|
59
|
+
& (voxel_coords < np.array(atlas.shape)),
|
|
60
|
+
axis=1
|
|
61
|
+
)
|
|
59
62
|
|
|
60
63
|
parcel_labels = np.zeros(len(points), dtype=int)
|
|
61
64
|
parcel_labels[valid] = atlas[
|
|
@@ -64,41 +67,54 @@ def create_structural_connectivity(
|
|
|
64
67
|
voxel_coords[valid, 2]
|
|
65
68
|
]
|
|
66
69
|
|
|
67
|
-
|
|
70
|
+
if threshold is None:
|
|
71
|
+
p1 = parcel_labels[0]
|
|
72
|
+
p2 = parcel_labels[-1]
|
|
73
|
+
|
|
74
|
+
if p1 == 0 or p2 == 0:
|
|
75
|
+
continue
|
|
76
|
+
else:
|
|
77
|
+
endpoints = []
|
|
68
78
|
|
|
69
|
-
|
|
79
|
+
for indices in (
|
|
80
|
+
range(len(points)),
|
|
81
|
+
range(len(points) - 1, -1, -1)
|
|
82
|
+
):
|
|
83
|
+
distance = 0.0
|
|
84
|
+
parcel = 0
|
|
85
|
+
previous = None
|
|
70
86
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
87
|
+
for i in indices:
|
|
88
|
+
if previous is not None:
|
|
89
|
+
distance += np.linalg.norm(
|
|
90
|
+
points[i] - points[previous]
|
|
91
|
+
)
|
|
74
92
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
points[i] - points[previous]
|
|
79
|
-
)
|
|
80
|
-
if parcel_labels[i] > 0:
|
|
81
|
-
parcel = parcel_labels[i]
|
|
82
|
-
break
|
|
83
|
-
previous = i
|
|
84
|
-
endpoints.append((parcel, distance))
|
|
93
|
+
if parcel_labels[i] > 0:
|
|
94
|
+
parcel = parcel_labels[i]
|
|
95
|
+
break
|
|
85
96
|
|
|
86
|
-
|
|
87
|
-
p2, d2 = endpoints[1]
|
|
97
|
+
previous = i
|
|
88
98
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
endpoints.append((parcel, distance))
|
|
100
|
+
|
|
101
|
+
p1, d1 = endpoints[0]
|
|
102
|
+
p2, d2 = endpoints[1]
|
|
103
|
+
|
|
104
|
+
if p1 == 0 or p2 == 0:
|
|
105
|
+
continue
|
|
106
|
+
|
|
107
|
+
if d1 > threshold or d2 > threshold:
|
|
108
|
+
continue
|
|
109
|
+
|
|
110
|
+
sc[p1-1, p2-1] += 1
|
|
93
111
|
|
|
94
|
-
p1 -= 1
|
|
95
|
-
p2 -= 1
|
|
96
|
-
sc[p1, p2] += 1
|
|
97
112
|
if p1 != p2:
|
|
98
|
-
sc[p2, p1] += 1
|
|
113
|
+
sc[p2-1, p1-1] += 1
|
|
99
114
|
|
|
100
115
|
if out_path:
|
|
101
116
|
np.save(out_path, sc)
|
|
102
117
|
|
|
103
118
|
return sc
|
|
104
119
|
|
|
120
|
+
|
|
@@ -9,7 +9,7 @@ def atlas_cfg_read(atlas_cfg_path):
|
|
|
9
9
|
|
|
10
10
|
Parameters
|
|
11
11
|
----------
|
|
12
|
-
atlas_cfg_path : Path
|
|
12
|
+
atlas_cfg_path : pathlib.Path
|
|
13
13
|
Path to the .json atlas configuration file. The configuration must
|
|
14
14
|
contain the following fields:
|
|
15
15
|
|
|
@@ -57,7 +57,7 @@ def tracts_cfg_read(tracts_cfg_path):
|
|
|
57
57
|
|
|
58
58
|
Parameters
|
|
59
59
|
----------
|
|
60
|
-
tracts_cfg_path : Path
|
|
60
|
+
tracts_cfg_path : pathlib.Path
|
|
61
61
|
Path to the .json tracts configuration file. The configuration must
|
|
62
62
|
contain the following fields:
|
|
63
63
|
|
|
@@ -102,7 +102,7 @@ def lesion_cfg_read(lesion_cfg_path: Path):
|
|
|
102
102
|
|
|
103
103
|
Parameters
|
|
104
104
|
----------
|
|
105
|
-
tracts_cfg_path : Path
|
|
105
|
+
tracts_cfg_path : pathlib.Path
|
|
106
106
|
Path to the .json tracts configuration file. The configuration must
|
|
107
107
|
contain the following fields:
|
|
108
108
|
|
|
@@ -24,19 +24,19 @@ def create_tract_list(
|
|
|
24
24
|
|
|
25
25
|
Parameters
|
|
26
26
|
----------
|
|
27
|
-
references_folder : Path
|
|
27
|
+
references_folder : pathlib.Path
|
|
28
28
|
Root directory containing the NIfTI reference images.
|
|
29
|
-
tracts_folder : Path
|
|
29
|
+
tracts_folder : pathlib.Path
|
|
30
30
|
Root directory containing the tractogram files.
|
|
31
31
|
|
|
32
32
|
Returns
|
|
33
33
|
-------
|
|
34
|
-
tuple[list[Path], list[Path]]
|
|
34
|
+
tuple[list[pathlib.Path], list[pathlib.Path]]
|
|
35
35
|
Two lists containing:
|
|
36
36
|
|
|
37
|
-
- tracts_pathlist : list[Path]
|
|
37
|
+
- tracts_pathlist : list[pathlib.Path]
|
|
38
38
|
Paths to the tractogram files.
|
|
39
|
-
- references_pathlist : list[Path]
|
|
39
|
+
- references_pathlist : list[pathlib.Path]
|
|
40
40
|
Paths to the corresponding NIfTI reference images.
|
|
41
41
|
|
|
42
42
|
Only tractograms with a corresponding NIfTI reference are included.
|
|
@@ -96,6 +96,7 @@ def create_tract_list(
|
|
|
96
96
|
# Verify that all NIfTIs are on the same grid
|
|
97
97
|
reference = None
|
|
98
98
|
|
|
99
|
+
# TODO too simple check, should be based on affine with real world coordinates.
|
|
99
100
|
for nifti_path in references_pathlist:
|
|
100
101
|
nifti = nib.nifti1.load(nifti_path)
|
|
101
102
|
|
|
@@ -117,14 +118,14 @@ def uncompress_trk_gz(
|
|
|
117
118
|
|
|
118
119
|
Parameters
|
|
119
120
|
----------
|
|
120
|
-
trk_path : Path
|
|
121
|
+
trk_path : pathlib.Path
|
|
121
122
|
Path to the input .trk or compressed .trk.gz file.
|
|
122
|
-
out_path : Path
|
|
123
|
+
out_path : pathlib.Path
|
|
123
124
|
Path where the uncompressed .trk file is saved.
|
|
124
125
|
|
|
125
126
|
Returns
|
|
126
127
|
-------
|
|
127
|
-
Path
|
|
128
|
+
pathlib.Path
|
|
128
129
|
Path to the resulting .trk file.
|
|
129
130
|
"""
|
|
130
131
|
if trk_path.suffix == ".gz":
|
|
@@ -143,7 +144,6 @@ def default_atlas_download(out_folder: Path):
|
|
|
143
144
|
atlas_path = atlas_cfg_folder / "glasser360_MNI152NLin2009cAsym.nii.gz"
|
|
144
145
|
atlas_labels_path = atlas_cfg_folder / "glasser360_labels.csv"
|
|
145
146
|
atlas_labels_path_txt = atlas_labels_path.with_suffix(".txt")
|
|
146
|
-
atlas_cfg_path = atlas_cfg_folder / "glasser360_config.json"
|
|
147
147
|
|
|
148
148
|
if atlas_path.exists():
|
|
149
149
|
warnings.warn(
|
|
@@ -205,9 +205,8 @@ def default_tracts_download(out_folder: Path):
|
|
|
205
205
|
"""Download the default HCP1065 tractography dataset and create its configuration.
|
|
206
206
|
|
|
207
207
|
The function downloads the HCP1065 average tractograms and their
|
|
208
|
-
corresponding NIfTI reference images
|
|
209
|
-
|
|
210
|
-
downloaded dataset. Existing folders are reused.
|
|
208
|
+
corresponding NIfTI reference images and creates a default configuration
|
|
209
|
+
file. Existing folders are reused.
|
|
211
210
|
|
|
212
211
|
Parameters
|
|
213
212
|
----------
|
|
@@ -306,7 +305,7 @@ def get_ref_space_tf(space: str, res: int = 1):
|
|
|
306
305
|
Returns
|
|
307
306
|
-------
|
|
308
307
|
nibabel.Nifti1Image
|
|
309
|
-
T1w
|
|
308
|
+
T1w brain mask template.
|
|
310
309
|
"""
|
|
311
310
|
t1w_ref_path = tf.get(space, resolution=res, desc=None, suffix="T1w")
|
|
312
311
|
brain_mask_path = tf.get(space, resolution=res, desc="brain", suffix="mask")
|
|
@@ -23,7 +23,7 @@ def register_affine(
|
|
|
23
23
|
|
|
24
24
|
Returns
|
|
25
25
|
-------
|
|
26
|
-
AffineMap
|
|
26
|
+
dipy.align.imaffine.AffineMap
|
|
27
27
|
Affine mapping from the moving image space to the static image space.
|
|
28
28
|
"""
|
|
29
29
|
|
|
@@ -91,7 +91,7 @@ def register_syn(
|
|
|
91
91
|
|
|
92
92
|
Returns
|
|
93
93
|
-------
|
|
94
|
-
DiffeomorphicMap
|
|
94
|
+
dipy.align.imwarp.DiffeomorphicMap
|
|
95
95
|
Diffeomorphic mapping from the moving image space to the static
|
|
96
96
|
image space.
|
|
97
97
|
"""
|
|
@@ -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,
|
|
6
|
+
from .utils import get_tract, get_streamlines_disconnection
|
|
7
7
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
|
|
@@ -20,19 +20,19 @@ def get_tracts_disconnections_severity(
|
|
|
20
20
|
|
|
21
21
|
Parameters
|
|
22
22
|
----------
|
|
23
|
-
tracts_path : list[Path]
|
|
23
|
+
tracts_path : list[pathlib.Path]
|
|
24
24
|
Paths to the tractogram files in order.
|
|
25
|
-
references_path : list[Path] | Path
|
|
25
|
+
references_path : list[pathlib.Path] | pathlib.Path
|
|
26
26
|
Paths to the NIfTI reference images corresponding to the tractograms.
|
|
27
27
|
If a single path is provided, it is used as the reference for all
|
|
28
28
|
tractograms. If a list, it should be in the same order as tracts_path.
|
|
29
|
-
lesion :
|
|
29
|
+
lesion : nibabel.Nifti1Image
|
|
30
30
|
NIfTI lesion mask. Voxels with values greater than zero are considered
|
|
31
31
|
part of the lesion.
|
|
32
|
-
disc_tracts_out_path : Path | None, optional
|
|
32
|
+
disc_tracts_out_path : pathlib.Path | None, optional
|
|
33
33
|
Directory where tractograms containing the disconnected streamlines
|
|
34
34
|
are saved. If None, disconnected tractograms are not saved.
|
|
35
|
-
disc_frame_out_path : Path | None, optional
|
|
35
|
+
disc_frame_out_path : pathlib.Path | None, optional
|
|
36
36
|
Directory where the resulting CSV file containing the disconnection
|
|
37
37
|
severity for each tract is saved. If None, the results are not saved.
|
|
38
38
|
|
|
@@ -93,15 +93,15 @@ def get_tracts_disconnections_severity(
|
|
|
93
93
|
|
|
94
94
|
if disc_frame_out_path:
|
|
95
95
|
disc_frame_out_path.mkdir(parents=True, exist_ok=True)
|
|
96
|
-
out_csv = disc_frame_out_path / "
|
|
96
|
+
out_csv = disc_frame_out_path / "ratio_discon_tract.csv"
|
|
97
97
|
disconnections_frame.to_csv(out_csv, index=False)
|
|
98
98
|
|
|
99
99
|
return disconnections_frame
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
def get_tracts_disconnections_map(
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
out_path : Path | None, optional
|
|
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
|
+
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- disconnections_map : nib.Nifti1Image
|
|
129
|
-
Voxel-wise ratio of disconnected to total streamline density.
|
|
130
|
-
- tdi_aggregated : nib.Nifti1Image
|
|
131
|
-
Track density image of all streamlines.
|
|
132
|
-
- tdi_disconnected : nib.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_mask.nii.gz"
|
|
140
|
-
tdi_disconnected_path = out_path / "tdi_disconnected_mask.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
|
-
|
|
151
|
-
out=np.zeros_like(
|
|
152
|
-
where=
|
|
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,
|
|
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
|
|
142
|
+
return disconnections_map
|
|
@@ -17,16 +17,16 @@ def get_tract(
|
|
|
17
17
|
|
|
18
18
|
Parameters
|
|
19
19
|
----------
|
|
20
|
-
tract_path : Path
|
|
20
|
+
tract_path : pathlib.Path
|
|
21
21
|
Path to the tractogram file.
|
|
22
|
-
reference_path : Path | None, optional
|
|
22
|
+
reference_path : pathlib.Path | None, optional
|
|
23
23
|
Path to a NIfTI image to use as the tractogram reference.
|
|
24
24
|
If provided, the tractogram is reconstructed in RASMM space
|
|
25
25
|
using this reference.
|
|
26
26
|
|
|
27
27
|
Returns
|
|
28
28
|
-------
|
|
29
|
-
StatefulTractogram
|
|
29
|
+
dipy.io.stateful_tractogram.StatefulTractogram
|
|
30
30
|
Loaded tractogram, optionally associated with the provided
|
|
31
31
|
reference image.
|
|
32
32
|
"""
|
|
@@ -51,18 +51,18 @@ def get_aggregated_tracts(
|
|
|
51
51
|
|
|
52
52
|
Parameters
|
|
53
53
|
----------
|
|
54
|
-
tracts_pathlist : list[Path]
|
|
54
|
+
tracts_pathlist : list[pathlib.Path]
|
|
55
55
|
Paths to the tractogram files to aggregate.
|
|
56
|
-
reference_path : Path | None, optional
|
|
56
|
+
reference_path : pathlib.Path | None, optional
|
|
57
57
|
Path to a NIfTI image to use as the reference for all tractograms.
|
|
58
58
|
If not provided, the first loaded tractogram is used as the reference.
|
|
59
|
-
out_path : Path | None, optional
|
|
59
|
+
out_path : pathlib.Path | None, optional
|
|
60
60
|
Path where the aggregated tractogram should be saved. If None,
|
|
61
61
|
the tractogram is not saved.
|
|
62
62
|
|
|
63
63
|
Returns
|
|
64
64
|
-------
|
|
65
|
-
StatefulTractogram
|
|
65
|
+
dipy.io.stateful_tractogram.StatefulTractogram
|
|
66
66
|
Aggregated tractogram containing the streamlines from all input
|
|
67
67
|
tractograms, clipped to the reference image grid.
|
|
68
68
|
"""
|
|
@@ -102,16 +102,16 @@ def clip_streamline_to_grid(
|
|
|
102
102
|
|
|
103
103
|
Parameters
|
|
104
104
|
----------
|
|
105
|
-
streamline : ndarray
|
|
105
|
+
streamline : numpy.ndarray
|
|
106
106
|
Streamline coordinates in world space.
|
|
107
|
-
inv_affine : ndarray
|
|
107
|
+
inv_affine : numpy.ndarray
|
|
108
108
|
Inverse affine transformation from world space to voxel space.
|
|
109
109
|
shape : tuple
|
|
110
110
|
Shape of the reference image grid.
|
|
111
111
|
|
|
112
112
|
Returns
|
|
113
113
|
-------
|
|
114
|
-
ndarray
|
|
114
|
+
numpy.ndarray
|
|
115
115
|
Streamline containing only the points that fall within the voxel grid.
|
|
116
116
|
"""
|
|
117
117
|
|
|
@@ -136,13 +136,13 @@ def clip_tractogram_to_grid(tract):
|
|
|
136
136
|
|
|
137
137
|
Parameters
|
|
138
138
|
----------
|
|
139
|
-
tract : StatefulTractogram
|
|
139
|
+
tract : dipy.io.stateful_tractogram.StatefulTractogram
|
|
140
140
|
Tractogram to clip. Its streamlines are expected to be in the
|
|
141
141
|
same world space as its reference image.
|
|
142
142
|
|
|
143
143
|
Returns
|
|
144
144
|
-------
|
|
145
|
-
StatefulTractogram
|
|
145
|
+
dipy.io.stateful_tractogram.StatefulTractogram
|
|
146
146
|
Tractogram containing only streamline points within the reference
|
|
147
147
|
voxel grid. Streamlines with fewer than two remaining points are
|
|
148
148
|
removed.
|
|
@@ -180,10 +180,10 @@ def get_streamlines_disconnection(
|
|
|
180
180
|
----------
|
|
181
181
|
tract : dipy.io.stateful_tractogram.StatefulTractogram
|
|
182
182
|
Tractogram from which to identify intersecting streamlines.
|
|
183
|
-
lesion :
|
|
183
|
+
lesion : nibabel.Nifti1Image
|
|
184
184
|
NIfTI lesion. Converted to binary mask where voxels with values
|
|
185
185
|
greater than zero are considered part of the lesion.
|
|
186
|
-
out_path : Path | None, optional
|
|
186
|
+
out_path : pathlib.Path | None, optional
|
|
187
187
|
Path where the disconnected streamlines should be saved. If None,
|
|
188
188
|
the tractogram is not saved.
|
|
189
189
|
|
|
@@ -223,15 +223,15 @@ def get_tdi(
|
|
|
223
223
|
|
|
224
224
|
Parameters
|
|
225
225
|
----------
|
|
226
|
-
tract : StatefulTractogram
|
|
226
|
+
tract : dipy.io.stateful_tractogram.StatefulTractogram
|
|
227
227
|
Tractogram from which to compute the track density image.
|
|
228
|
-
out_path : Path | None, optional
|
|
228
|
+
out_path : pathlib.Path | None, optional
|
|
229
229
|
Path where the TDI NIfTI image should be saved. If None, the image
|
|
230
230
|
is not saved.
|
|
231
231
|
|
|
232
232
|
Returns
|
|
233
233
|
-------
|
|
234
|
-
|
|
234
|
+
nibabel.Nifti1Image
|
|
235
235
|
NIfTI image containing the number of streamlines passing through
|
|
236
236
|
each voxel.
|
|
237
237
|
"""
|
|
@@ -1,6 +1,7 @@
|
|
|
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
|
+
from pyLQT.lesion_metrics.network.utils import create_structural_connectivity
|
|
4
5
|
from pyLQT.lesion_metrics.grey_matter.metrics import get_parcel_damage
|
|
5
6
|
from pyLQT.lesion_metrics.utils.configs import atlas_cfg_read, tracts_cfg_read, lesion_cfg_read
|
|
6
7
|
from pyLQT.lesion_metrics.utils.downloads import default_tracts_download, default_atlas_download, create_tract_list, uncompress_trk_gz, get_ref_space_tf
|
|
@@ -17,6 +18,7 @@ def run_pyLQT(
|
|
|
17
18
|
atlas_cfg=None,
|
|
18
19
|
tracts_cfg=None,
|
|
19
20
|
registration_type="syn",
|
|
21
|
+
sc_distance_threshold=5.0,
|
|
20
22
|
spared_threshold=0.5,
|
|
21
23
|
delete_tmp=False,
|
|
22
24
|
):
|
|
@@ -36,6 +38,9 @@ def run_pyLQT(
|
|
|
36
38
|
tractography dataset is downloaded.
|
|
37
39
|
registration_type : {"affine", "syn"}, default="syn"
|
|
38
40
|
Registration method used to map the lesion and atlas to tract space.
|
|
41
|
+
sc_distance_threshold : float, default=5.0
|
|
42
|
+
Threshold in (0, inf) for distance filtering of tracts endpoints in
|
|
43
|
+
structural connectivity computation.
|
|
39
44
|
spared_threshold : float, default=0.5
|
|
40
45
|
Threshold in (0, 1) for spared parcel-to-parcel connectivity.
|
|
41
46
|
delete_tmp : bool, default=False
|
|
@@ -83,27 +88,6 @@ def run_pyLQT(
|
|
|
83
88
|
tracts_ref_space = nib.load(tracts_space)
|
|
84
89
|
else:
|
|
85
90
|
tracts_ref_space = get_ref_space_tf(tracts_space)
|
|
86
|
-
|
|
87
|
-
#### TEST ####
|
|
88
|
-
import numpy as np
|
|
89
|
-
from nibabel.orientations import aff2axcodes
|
|
90
|
-
for lesion_path in lesion_folder.glob("*.nii*"):
|
|
91
|
-
lesion = nib.load(lesion_path)
|
|
92
|
-
|
|
93
|
-
print("Lesion shape:", lesion.shape)
|
|
94
|
-
print("Moving reference shape:", lesion_ref_space.shape)
|
|
95
|
-
|
|
96
|
-
print("Lesion affine:\n", lesion.affine)
|
|
97
|
-
print("Moving reference affine:\n", lesion_ref_space.affine)
|
|
98
|
-
|
|
99
|
-
print(
|
|
100
|
-
"Same grid:",
|
|
101
|
-
lesion.shape == lesion_ref_space.shape
|
|
102
|
-
and np.allclose(lesion.affine, lesion_ref_space.affine),
|
|
103
|
-
)
|
|
104
|
-
print("Lesion:", aff2axcodes(lesion.affine))
|
|
105
|
-
print("Moving reference:", aff2axcodes(lesion_ref_space.affine))
|
|
106
|
-
#### TEST ####
|
|
107
91
|
|
|
108
92
|
registrator = (register_affine if registration_type == "affine" else register_syn)
|
|
109
93
|
|
|
@@ -126,7 +110,7 @@ def run_pyLQT(
|
|
|
126
110
|
tracts_pathlist = []
|
|
127
111
|
for tract_path in tracts_pathlist_gz:
|
|
128
112
|
relative_path = tract_path.relative_to(tracts_folder)
|
|
129
|
-
out_path = tmp_folder / relative_path.with_suffix("")
|
|
113
|
+
out_path = tmp_folder / f"{tracts_name}_uncompressed" / relative_path.with_suffix("")
|
|
130
114
|
out_path.parent.mkdir(parents=True, exist_ok=True)
|
|
131
115
|
|
|
132
116
|
tracts_pathlist.append(uncompress_trk_gz(tract_path, out_path))
|
|
@@ -136,6 +120,17 @@ def run_pyLQT(
|
|
|
136
120
|
tracts_pathlist=tracts_pathlist,
|
|
137
121
|
out_path=aggregated_tracts_path,
|
|
138
122
|
)
|
|
123
|
+
|
|
124
|
+
structural_connectivity_aggregated = create_structural_connectivity(
|
|
125
|
+
tract=aggregated_tracts,
|
|
126
|
+
atlas_resampled=atlas_trans,
|
|
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
|
+
|
|
139
134
|
|
|
140
135
|
for lesion_path in lesion_folder.glob("*.nii*"):
|
|
141
136
|
lesion_name = lesion_path.name.removesuffix(".nii.gz").removesuffix(".nii")
|
|
@@ -161,6 +156,18 @@ def run_pyLQT(
|
|
|
161
156
|
out_path=aggregated_tracts_disconnected_path,
|
|
162
157
|
)
|
|
163
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)
|
|
161
|
+
structural_connectivity_disconnected = create_structural_connectivity(
|
|
162
|
+
tract=aggregated_tracts_disconnected,
|
|
163
|
+
atlas_resampled=atlas_trans,
|
|
164
|
+
threshold=sc_distance_threshold,
|
|
165
|
+
out_path=out_dir / "parcel_wise_disconnection_severity" / "structural_connectivity_disconnected.npy"
|
|
166
|
+
)
|
|
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)
|
|
164
171
|
|
|
165
172
|
get_parcel_damage(
|
|
166
173
|
lesion=lesion_trans,
|
|
@@ -179,22 +186,21 @@ def run_pyLQT(
|
|
|
179
186
|
)
|
|
180
187
|
|
|
181
188
|
get_tracts_disconnections_map(
|
|
182
|
-
|
|
183
|
-
|
|
189
|
+
tdi=tdi_aggregated,
|
|
190
|
+
tdi_disconnected=tdi_aggregated_disconnected,
|
|
184
191
|
out_path=out_dir / "wm_disconnections_map",
|
|
185
192
|
)
|
|
186
193
|
|
|
187
|
-
|
|
194
|
+
_, per_spared_connections = (
|
|
188
195
|
get_parcel_wise_disconnection_severity(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
atlas=atlas_trans,
|
|
196
|
+
structural_connectivity=structural_connectivity_aggregated,
|
|
197
|
+
structural_connectivity_disconnected=structural_connectivity_disconnected,
|
|
192
198
|
out_path=out_dir / "parcel_wise_disconnection_severity",
|
|
193
199
|
)
|
|
194
200
|
)
|
|
195
201
|
|
|
196
202
|
get_sspl_increase(
|
|
197
|
-
structural_connectivity=
|
|
203
|
+
structural_connectivity=structural_connectivity_aggregated,
|
|
198
204
|
per_spared_connections=per_spared_connections,
|
|
199
205
|
out_path=out_dir / "sspl_increase",
|
|
200
206
|
spared_threshold=spared_threshold,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyLQT
|
|
3
|
-
Version: 1.0.
|
|
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
|
|
@@ -107,6 +107,9 @@ pyLQT --lesion_cfg <path/to/lesion_config> --out_folder <path/to/outputs>
|
|
|
107
107
|
| `--spared_threshold` | `0.5` | Float between `0` and `1` | Threshold used to define spared parcel-to-parcel connectivity. |
|
|
108
108
|
| `--delete_tmp` | `True` | `True`, `False` | Whether to delete temporary files generated during processing. |
|
|
109
109
|
|
|
110
|
+
## Outputs
|
|
111
|
+
|
|
112
|
+
TODO
|
|
110
113
|
|
|
111
114
|
## Dependencies
|
|
112
115
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|