1 |
commit: 34adca35bfa7ee9e22c7456989b67c732a9bb511 |
2 |
Author: Horea Christian <chr <AT> chymera <DOT> eu> |
3 |
AuthorDate: Sun Jan 29 13:36:16 2023 +0000 |
4 |
Commit: Horea Christian <horea.christ <AT> gmail <DOT> com> |
5 |
CommitDate: Sun Jan 29 13:36:16 2023 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=34adca35 |
7 |
|
8 |
sci-libs/nipype: version bump 1.8.4 |
9 |
|
10 |
Signed-off-by: Horea Christian <chr <AT> chymera.eu> |
11 |
|
12 |
.../nipype-1.8.4-dependency_compatibility.patch | 575 +++++++++++++++++++++ |
13 |
sci-libs/nipype/nipype-1.8.4.ebuild | 92 ++++ |
14 |
2 files changed, 667 insertions(+) |
15 |
|
16 |
diff --git a/sci-libs/nipype/files/nipype-1.8.4-dependency_compatibility.patch b/sci-libs/nipype/files/nipype-1.8.4-dependency_compatibility.patch |
17 |
new file mode 100644 |
18 |
index 000000000..9811139e7 |
19 |
--- /dev/null |
20 |
+++ b/sci-libs/nipype/files/nipype-1.8.4-dependency_compatibility.patch |
21 |
@@ -0,0 +1,575 @@ |
22 |
+From a31870d0f9dc0e774f1cf9d18351586f78ecb252 Mon Sep 17 00:00:00 2001 |
23 |
+From: Chris Markiewicz <effigies@×××××.com> |
24 |
+Date: Sat, 28 Jan 2023 08:11:54 -0500 |
25 |
+Subject: [PATCH 1/9] FIX: Set dtypes for integer test images |
26 |
+ |
27 |
+NiBabel 4 began warning that int64 images would error, and NiBabel 5 |
28 |
+began erroring if not passed an explicit dtype or header. |
29 |
+ |
30 |
+We don't need int64 images, just set some sensible dtypes. |
31 |
+--- |
32 |
+ nipype/algorithms/tests/test_ErrorMap.py | 2 +- |
33 |
+ nipype/algorithms/tests/test_TSNR.py | 3 ++- |
34 |
+ nipype/algorithms/tests/test_metrics.py | 2 +- |
35 |
+ 3 files changed, 4 insertions(+), 3 deletions(-) |
36 |
+ |
37 |
+diff --git a/nipype/algorithms/tests/test_ErrorMap.py b/nipype/algorithms/tests/test_ErrorMap.py |
38 |
+index 98f05d8e17..adac507bad 100644 |
39 |
+--- a/nipype/algorithms/tests/test_ErrorMap.py |
40 |
++++ b/nipype/algorithms/tests/test_ErrorMap.py |
41 |
+@@ -17,7 +17,7 @@ def test_errormap(tmpdir): |
42 |
+ volume1 = np.array([[[2.0, 8.0], [1.0, 2.0]], [[1.0, 9.0], [0.0, 3.0]]]) |
43 |
+ # Alan Turing's birthday |
44 |
+ volume2 = np.array([[[0.0, 7.0], [2.0, 3.0]], [[1.0, 9.0], [1.0, 2.0]]]) |
45 |
+- mask = np.array([[[1, 0], [0, 1]], [[1, 0], [0, 1]]]) |
46 |
++ mask = np.array([[[1, 0], [0, 1]], [[1, 0], [0, 1]]], dtype=np.uint8) |
47 |
+ |
48 |
+ img1 = nb.Nifti1Image(volume1, np.eye(4)) |
49 |
+ img2 = nb.Nifti1Image(volume2, np.eye(4)) |
50 |
+diff --git a/nipype/algorithms/tests/test_TSNR.py b/nipype/algorithms/tests/test_TSNR.py |
51 |
+index 26c1019b63..320bec8ab2 100644 |
52 |
+--- a/nipype/algorithms/tests/test_TSNR.py |
53 |
++++ b/nipype/algorithms/tests/test_TSNR.py |
54 |
+@@ -131,5 +131,6 @@ def assert_unchanged(self, expected_ranges): |
55 |
+ [ |
56 |
+ [[[2, 4, 3, 9, 1], [3, 6, 4, 7, 4]], [[8, 3, 4, 6, 2], [4, 0, 4, 4, 2]]], |
57 |
+ [[[9, 7, 5, 5, 7], [7, 8, 4, 8, 4]], [[0, 4, 7, 1, 7], [6, 8, 8, 8, 7]]], |
58 |
+- ] |
59 |
++ ], |
60 |
++ dtype=np.int16, |
61 |
+ ) |
62 |
+diff --git a/nipype/algorithms/tests/test_metrics.py b/nipype/algorithms/tests/test_metrics.py |
63 |
+index ad7502992e..3652fc2ce5 100644 |
64 |
+--- a/nipype/algorithms/tests/test_metrics.py |
65 |
++++ b/nipype/algorithms/tests/test_metrics.py |
66 |
+@@ -45,7 +45,7 @@ def test_fuzzy_overlap(tmpdir): |
67 |
+ |
68 |
+ # Just considering the mask, the central pixel |
69 |
+ # that raised the index now is left aside. |
70 |
+- data = np.zeros((3, 3, 3), dtype=int) |
71 |
++ data = np.zeros((3, 3, 3), dtype=np.uint8) |
72 |
+ data[0, 0, 0] = 1 |
73 |
+ data[2, 2, 2] = 1 |
74 |
+ nb.Nifti1Image(data, np.eye(4)).to_filename("mask.nii.gz") |
75 |
+ |
76 |
+From 443492e82f3b197ad739cb244912ced652853a8d Mon Sep 17 00:00:00 2001 |
77 |
+From: Chris Markiewicz <effigies@×××××.com> |
78 |
+Date: Sat, 28 Jan 2023 08:43:07 -0500 |
79 |
+Subject: [PATCH 2/9] FIX: Coerce depidx to lil_matrix |
80 |
+ |
81 |
+--- |
82 |
+ nipype/pipeline/plugins/base.py | 18 +++++++++++++----- |
83 |
+ 1 file changed, 13 insertions(+), 5 deletions(-) |
84 |
+ |
85 |
+diff --git a/nipype/pipeline/plugins/base.py b/nipype/pipeline/plugins/base.py |
86 |
+index a927b24686..3d600dda55 100644 |
87 |
+--- a/nipype/pipeline/plugins/base.py |
88 |
++++ b/nipype/pipeline/plugins/base.py |
89 |
+@@ -21,6 +21,18 @@ |
90 |
+ logger = logging.getLogger("nipype.workflow") |
91 |
+ |
92 |
+ |
93 |
++def _graph_to_lil_matrix(graph, nodelist): |
94 |
++ """Provide a sparse linked list matrix across various NetworkX versions""" |
95 |
++ import scipy.sparse as ssp |
96 |
++ |
97 |
++ try: |
98 |
++ from networkx import to_scipy_sparse_array |
99 |
++ except ImportError: # NetworkX < 2.7 |
100 |
++ from networkx import to_scipy_sparse_matrix as to_scipy_sparse_array |
101 |
++ |
102 |
++ return ssp.lil_matrix(to_scipy_sparse_array(graph, nodelist=nodelist, format="lil")) |
103 |
++ |
104 |
++ |
105 |
+ class PluginBase(object): |
106 |
+ """Base class for plugins.""" |
107 |
+ |
108 |
+@@ -431,12 +443,8 @@ def _task_finished_cb(self, jobid, cached=False): |
109 |
+ |
110 |
+ def _generate_dependency_list(self, graph): |
111 |
+ """Generates a dependency list for a list of graphs.""" |
112 |
+- import networkx as nx |
113 |
+- |
114 |
+ self.procs, _ = topological_sort(graph) |
115 |
+- self.depidx = nx.to_scipy_sparse_matrix( |
116 |
+- graph, nodelist=self.procs, format="lil" |
117 |
+- ) |
118 |
++ self.depidx = _graph_to_lil_matrix(graph, nodelist=self.procs) |
119 |
+ self.refidx = self.depidx.astype(int) |
120 |
+ self.proc_done = np.zeros(len(self.procs), dtype=bool) |
121 |
+ self.proc_pending = np.zeros(len(self.procs), dtype=bool) |
122 |
+ |
123 |
+From 34ef6c2ff89f327fcf2951b792ef38b6d56f8c4e Mon Sep 17 00:00:00 2001 |
124 |
+From: Chris Markiewicz <effigies@×××××.com> |
125 |
+Date: Sat, 28 Jan 2023 11:57:54 -0500 |
126 |
+Subject: [PATCH 3/9] FIX: Accept "str" in dipy type (includes "string") |
127 |
+ |
128 |
+--- |
129 |
+ nipype/interfaces/dipy/base.py | 6 +++--- |
130 |
+ 1 file changed, 3 insertions(+), 3 deletions(-) |
131 |
+ |
132 |
+diff --git a/nipype/interfaces/dipy/base.py b/nipype/interfaces/dipy/base.py |
133 |
+index d8a1c0fbf5..161ed33227 100644 |
134 |
+--- a/nipype/interfaces/dipy/base.py |
135 |
++++ b/nipype/interfaces/dipy/base.py |
136 |
+@@ -110,7 +110,7 @@ def convert_to_traits_type(dipy_type, is_file=False): |
137 |
+ """Convert DIPY type to Traits type.""" |
138 |
+ dipy_type = dipy_type.lower() |
139 |
+ is_mandatory = bool("optional" not in dipy_type) |
140 |
+- if "variable" in dipy_type and "string" in dipy_type: |
141 |
++ if "variable" in dipy_type and "str" in dipy_type: |
142 |
+ return traits.ListStr, is_mandatory |
143 |
+ elif "variable" in dipy_type and "int" in dipy_type: |
144 |
+ return traits.ListInt, is_mandatory |
145 |
+@@ -120,9 +120,9 @@ def convert_to_traits_type(dipy_type, is_file=False): |
146 |
+ return traits.ListBool, is_mandatory |
147 |
+ elif "variable" in dipy_type and "complex" in dipy_type: |
148 |
+ return traits.ListComplex, is_mandatory |
149 |
+- elif "string" in dipy_type and not is_file: |
150 |
++ elif "str" in dipy_type and not is_file: |
151 |
+ return traits.Str, is_mandatory |
152 |
+- elif "string" in dipy_type and is_file: |
153 |
++ elif "str" in dipy_type and is_file: |
154 |
+ return File, is_mandatory |
155 |
+ elif "int" in dipy_type: |
156 |
+ return traits.Int, is_mandatory |
157 |
+ |
158 |
+From 83c8cf86d6bbb0dc04aa58dbe5119fd864342d9c Mon Sep 17 00:00:00 2001 |
159 |
+From: Chris Markiewicz <effigies@×××××.com> |
160 |
+Date: Sat, 28 Jan 2023 11:55:34 -0500 |
161 |
+Subject: [PATCH 4/9] MNT: Update requirements from info.py |
162 |
+ |
163 |
+--- |
164 |
+ requirements.txt | 6 +++--- |
165 |
+ 1 file changed, 3 insertions(+), 3 deletions(-) |
166 |
+ |
167 |
+diff --git a/requirements.txt b/requirements.txt |
168 |
+index afec34ebfd..331e2c5def 100644 |
169 |
+--- a/requirements.txt |
170 |
++++ b/requirements.txt |
171 |
+@@ -2,8 +2,7 @@ |
172 |
+ click>=6.6.0 |
173 |
+ networkx>=2.0 |
174 |
+ nibabel>=2.1.0 |
175 |
+-numpy>=1.13 ; python_version < "3.7" |
176 |
+-numpy>=1.15.3 ; python_version >= "3.7" |
177 |
++numpy>=1.17 |
178 |
+ packaging |
179 |
+ prov>=1.5.2 |
180 |
+ pydot>=1.2.3 |
181 |
+@@ -11,6 +10,7 @@ python-dateutil>=2.2 |
182 |
+ rdflib>=5.0.0 |
183 |
+ scipy>=0.14 |
184 |
+ simplejson>=3.8.0 |
185 |
+-traits>=4.6,!=5.0 |
186 |
++traits>=4.6,<6.4,!=5.0 |
187 |
+ filelock>=3.0.0 |
188 |
+ etelemetry>=0.2.0 |
189 |
++looseversion |
190 |
+ |
191 |
+From 24c55a6f48aa658320ff35283b6f91ec38b13a40 Mon Sep 17 00:00:00 2001 |
192 |
+From: Horea Christian <chr@×××××××.eu> |
193 |
+Date: Thu, 26 Jan 2023 02:28:33 -0500 |
194 |
+Subject: [PATCH 5/9] Writing pickles directly as networkx no longer ships |
195 |
+ write_gpickle |
196 |
+ |
197 |
+--- |
198 |
+ nipype/interfaces/cmtk/cmtk.py | 12 ++++++++---- |
199 |
+ nipype/interfaces/cmtk/nbs.py | 7 +++++-- |
200 |
+ nipype/interfaces/cmtk/nx.py | 12 ++++++++---- |
201 |
+ nipype/interfaces/cmtk/tests/test_nbs.py | 4 +++- |
202 |
+ 4 files changed, 24 insertions(+), 11 deletions(-) |
203 |
+ |
204 |
+diff --git a/nipype/interfaces/cmtk/cmtk.py b/nipype/interfaces/cmtk/cmtk.py |
205 |
+index 8775a8517e..8df7a1c5ad 100644 |
206 |
+--- a/nipype/interfaces/cmtk/cmtk.py |
207 |
++++ b/nipype/interfaces/cmtk/cmtk.py |
208 |
+@@ -226,7 +226,8 @@ def cmat( |
209 |
+ # Add node information from specified parcellation scheme |
210 |
+ path, name, ext = split_filename(resolution_network_file) |
211 |
+ if ext == ".pck": |
212 |
+- gp = nx.read_gpickle(resolution_network_file) |
213 |
++ with open(resolution_network_file, 'rb') as f: |
214 |
++ gp = pickle.load(f) |
215 |
+ elif ext == ".graphml": |
216 |
+ gp = nx.read_graphml(resolution_network_file) |
217 |
+ else: |
218 |
+@@ -379,7 +380,8 @@ def cmat( |
219 |
+ fibdev.add_edge(u, v, weight=di["fiber_length_std"]) |
220 |
+ |
221 |
+ iflogger.info("Writing network as %s", matrix_name) |
222 |
+- nx.write_gpickle(G, op.abspath(matrix_name)) |
223 |
++ with open(op.abspath(matrix_name), 'wb') as f: |
224 |
++ pickle.dump(G, f, pickle.HIGHEST_PROTOCOL) |
225 |
+ |
226 |
+ numfib_mlab = nx.to_numpy_matrix(numfib, dtype=int) |
227 |
+ numfib_dict = {"number_of_fibers": numfib_mlab} |
228 |
+@@ -394,7 +396,8 @@ def cmat( |
229 |
+ path, name, ext = split_filename(matrix_name) |
230 |
+ intersection_matrix_name = op.abspath(name + "_intersections") + ext |
231 |
+ iflogger.info("Writing intersection network as %s", intersection_matrix_name) |
232 |
+- nx.write_gpickle(I, intersection_matrix_name) |
233 |
++ with open(intersection_matrix_name, 'wb') as f: |
234 |
++ pickle.dump(I, f, pickle.HIGHEST_PROTOCOL) |
235 |
+ |
236 |
+ path, name, ext = split_filename(matrix_mat_name) |
237 |
+ if not ext == ".mat": |
238 |
+@@ -1070,7 +1073,8 @@ def create_nodes(roi_file, resolution_network_file, out_filename): |
239 |
+ ) |
240 |
+ ) |
241 |
+ G.nodes[int(u)]["dn_position"] = tuple([xyz[0], xyz[2], -xyz[1]]) |
242 |
+- nx.write_gpickle(G, out_filename) |
243 |
++ with open(out_filename, 'wb') as f: |
244 |
++ pickle.dump(G, f, pickle.HIGHEST_PROTOCOL) |
245 |
+ return out_filename |
246 |
+ |
247 |
+ |
248 |
+diff --git a/nipype/interfaces/cmtk/nbs.py b/nipype/interfaces/cmtk/nbs.py |
249 |
+index 4e1db9ffb7..57d63897c7 100644 |
250 |
+--- a/nipype/interfaces/cmtk/nbs.py |
251 |
++++ b/nipype/interfaces/cmtk/nbs.py |
252 |
+@@ -6,6 +6,7 @@ |
253 |
+ |
254 |
+ import numpy as np |
255 |
+ import networkx as nx |
256 |
++import pickle |
257 |
+ |
258 |
+ from ... import logging |
259 |
+ from ..base import ( |
260 |
+@@ -172,12 +173,14 @@ def _run_interface(self, runtime): |
261 |
+ |
262 |
+ path = op.abspath("NBS_Result_" + details) |
263 |
+ iflogger.info(path) |
264 |
+- nx.write_gpickle(nbsgraph, path) |
265 |
++ with open(path, 'wb') as f: |
266 |
++ pickle.dump(nbsgraph, f, pickle.HIGHEST_PROTOCOL) |
267 |
+ iflogger.info("Saving output NBS edge network as %s", path) |
268 |
+ |
269 |
+ pval_path = op.abspath("NBS_P_vals_" + details) |
270 |
+ iflogger.info(pval_path) |
271 |
+- nx.write_gpickle(nbs_pval_graph, pval_path) |
272 |
++ with open(pval_path, 'wb') as f: |
273 |
++ pickle.dump(nbs_pval_graph, f, pickle.HIGHEST_PROTOCOL) |
274 |
+ iflogger.info("Saving output p-value network as %s", pval_path) |
275 |
+ return runtime |
276 |
+ |
277 |
+diff --git a/nipype/interfaces/cmtk/nx.py b/nipype/interfaces/cmtk/nx.py |
278 |
+index aaf4bece39..a662eb65c6 100644 |
279 |
+--- a/nipype/interfaces/cmtk/nx.py |
280 |
++++ b/nipype/interfaces/cmtk/nx.py |
281 |
+@@ -200,7 +200,8 @@ def average_networks(in_files, ntwk_res_file, group_id): |
282 |
+ |
283 |
+ # Writes the networks and returns the name |
284 |
+ network_name = group_id + "_average.pck" |
285 |
+- nx.write_gpickle(avg_ntwk, op.abspath(network_name)) |
286 |
++ with open(op.abspath(network_name), 'wb') as f: |
287 |
++ pickle.dump(avg_ntwk, f, pickle.HIGHEST_PROTOCOL) |
288 |
+ iflogger.info("Saving average network as %s", op.abspath(network_name)) |
289 |
+ avg_ntwk = fix_keys_for_gexf(avg_ntwk) |
290 |
+ network_name = group_id + "_average.gexf" |
291 |
+@@ -483,7 +484,8 @@ def _run_interface(self, runtime): |
292 |
+ for key in list(node_measures.keys()): |
293 |
+ newntwk = add_node_data(node_measures[key], ntwk) |
294 |
+ out_file = op.abspath(self._gen_outfilename(key, "pck")) |
295 |
+- nx.write_gpickle(newntwk, out_file) |
296 |
++ with open(out_file, 'wb') as f: |
297 |
++ pickle.dump(newntwk, f, pickle.HIGHEST_PROTOCOL) |
298 |
+ nodentwks.append(out_file) |
299 |
+ if isdefined(self.inputs.out_node_metrics_matlab): |
300 |
+ node_out_file = op.abspath(self.inputs.out_node_metrics_matlab) |
301 |
+@@ -497,7 +499,8 @@ def _run_interface(self, runtime): |
302 |
+ for key in list(edge_measures.keys()): |
303 |
+ newntwk = add_edge_data(edge_measures[key], ntwk) |
304 |
+ out_file = op.abspath(self._gen_outfilename(key, "pck")) |
305 |
+- nx.write_gpickle(newntwk, out_file) |
306 |
++ with open(out_file, 'wb') as f: |
307 |
++ pickle.dump(newntwk, f, pickle.HIGHEST_PROTOCOL) |
308 |
+ edgentwks.append(out_file) |
309 |
+ if isdefined(self.inputs.out_edge_metrics_matlab): |
310 |
+ edge_out_file = op.abspath(self.inputs.out_edge_metrics_matlab) |
311 |
+@@ -521,7 +524,8 @@ def _run_interface(self, runtime): |
312 |
+ out_file = op.abspath( |
313 |
+ self._gen_outfilename(self.inputs.out_k_crust, "pck") |
314 |
+ ) |
315 |
+- nx.write_gpickle(ntwk_measures[key], out_file) |
316 |
++ with open(out_file, 'wb') as f: |
317 |
++ pickle.dump(ntwk_measures[key], f, pickle.HIGHEST_PROTOCOL) |
318 |
+ kntwks.append(out_file) |
319 |
+ gpickled.extend(kntwks) |
320 |
+ |
321 |
+diff --git a/nipype/interfaces/cmtk/tests/test_nbs.py b/nipype/interfaces/cmtk/tests/test_nbs.py |
322 |
+index 46da939f1a..7a60b407a4 100644 |
323 |
+--- a/nipype/interfaces/cmtk/tests/test_nbs.py |
324 |
++++ b/nipype/interfaces/cmtk/tests/test_nbs.py |
325 |
+@@ -2,6 +2,7 @@ |
326 |
+ from ....utils.misc import package_check |
327 |
+ import numpy as np |
328 |
+ import networkx as nx |
329 |
++import pickle |
330 |
+ import pytest |
331 |
+ |
332 |
+ have_cv = True |
333 |
+@@ -20,7 +21,8 @@ def creating_graphs(tmpdir): |
334 |
+ G = nx.from_numpy_matrix(graph) |
335 |
+ out_file = tmpdir.strpath + graphnames[idx] + ".pck" |
336 |
+ # Save as pck file |
337 |
+- nx.write_gpickle(G, out_file) |
338 |
++ with open(out_file, 'wb') as f: |
339 |
++ pickle.dump(G, f, pickle.HIGHEST_PROTOCOL) |
340 |
+ graphlist.append(out_file) |
341 |
+ return graphlist |
342 |
+ |
343 |
+ |
344 |
+From b9a8e2000be9ce30a94aca85453d5cf4e32e10ec Mon Sep 17 00:00:00 2001 |
345 |
+From: Horea Christian <chr@×××××××.eu> |
346 |
+Date: Thu, 26 Jan 2023 02:03:39 -0500 |
347 |
+Subject: [PATCH 6/9] updating networkx from_numpy_{matrix,array} |
348 |
+ |
349 |
+--- |
350 |
+ nipype/interfaces/cmtk/cmtk.py | 2 +- |
351 |
+ nipype/interfaces/cmtk/nbs.py | 4 ++-- |
352 |
+ nipype/interfaces/cmtk/tests/test_nbs.py | 2 +- |
353 |
+ 3 files changed, 4 insertions(+), 4 deletions(-) |
354 |
+ |
355 |
+diff --git a/nipype/interfaces/cmtk/cmtk.py b/nipype/interfaces/cmtk/cmtk.py |
356 |
+index 8df7a1c5ad..fc730b1166 100644 |
357 |
+--- a/nipype/interfaces/cmtk/cmtk.py |
358 |
++++ b/nipype/interfaces/cmtk/cmtk.py |
359 |
+@@ -264,7 +264,7 @@ def cmat( |
360 |
+ ) |
361 |
+ intersection_matrix = np.matrix(intersection_matrix) |
362 |
+ I = G.copy() |
363 |
+- H = nx.from_numpy_matrix(np.matrix(intersection_matrix)) |
364 |
++ H = nx.from_numpy_array(np.matrix(intersection_matrix)) |
365 |
+ H = nx.relabel_nodes(H, lambda x: x + 1) # relabel nodes so they start at 1 |
366 |
+ I.add_weighted_edges_from( |
367 |
+ ((u, v, d["weight"]) for u, v, d in H.edges(data=True)) |
368 |
+diff --git a/nipype/interfaces/cmtk/nbs.py b/nipype/interfaces/cmtk/nbs.py |
369 |
+index 57d63897c7..b0a8b5df33 100644 |
370 |
+--- a/nipype/interfaces/cmtk/nbs.py |
371 |
++++ b/nipype/interfaces/cmtk/nbs.py |
372 |
+@@ -150,8 +150,8 @@ def _run_interface(self, runtime): |
373 |
+ pADJ[x, y] = PVAL[idx] |
374 |
+ |
375 |
+ # Create networkx graphs from the adjacency matrix |
376 |
+- nbsgraph = nx.from_numpy_matrix(ADJ) |
377 |
+- nbs_pval_graph = nx.from_numpy_matrix(pADJ) |
378 |
++ nbsgraph = nx.from_numpy_array(ADJ) |
379 |
++ nbs_pval_graph = nx.from_numpy_array(pADJ) |
380 |
+ |
381 |
+ # Relabel nodes because they should not start at zero for our convention |
382 |
+ nbsgraph = nx.relabel_nodes(nbsgraph, lambda x: x + 1) |
383 |
+diff --git a/nipype/interfaces/cmtk/tests/test_nbs.py b/nipype/interfaces/cmtk/tests/test_nbs.py |
384 |
+index 7a60b407a4..6323546c1e 100644 |
385 |
+--- a/nipype/interfaces/cmtk/tests/test_nbs.py |
386 |
++++ b/nipype/interfaces/cmtk/tests/test_nbs.py |
387 |
+@@ -18,7 +18,7 @@ def creating_graphs(tmpdir): |
388 |
+ graphnames = ["name" + str(i) for i in range(6)] |
389 |
+ for idx, name in enumerate(graphnames): |
390 |
+ graph = np.random.rand(10, 10) |
391 |
+- G = nx.from_numpy_matrix(graph) |
392 |
++ G = nx.from_numpy_array(graph) |
393 |
+ out_file = tmpdir.strpath + graphnames[idx] + ".pck" |
394 |
+ # Save as pck file |
395 |
+ with open(out_file, 'wb') as f: |
396 |
+ |
397 |
+From 7aa7c5968cf28afed9aca658bca28470afbfeb9f Mon Sep 17 00:00:00 2001 |
398 |
+From: Chris Markiewicz <effigies@×××××.com> |
399 |
+Date: Sat, 28 Jan 2023 12:45:17 -0500 |
400 |
+Subject: [PATCH 7/9] FIX: Purge nx.to_numpy_matrix |
401 |
+ |
402 |
+--- |
403 |
+ nipype/interfaces/cmtk/cmtk.py | 8 ++++---- |
404 |
+ nipype/interfaces/cmtk/nbs.py | 2 +- |
405 |
+ 2 files changed, 5 insertions(+), 5 deletions(-) |
406 |
+ |
407 |
+diff --git a/nipype/interfaces/cmtk/cmtk.py b/nipype/interfaces/cmtk/cmtk.py |
408 |
+index fc730b1166..00c134fc37 100644 |
409 |
+--- a/nipype/interfaces/cmtk/cmtk.py |
410 |
++++ b/nipype/interfaces/cmtk/cmtk.py |
411 |
+@@ -383,13 +383,13 @@ def cmat( |
412 |
+ with open(op.abspath(matrix_name), 'wb') as f: |
413 |
+ pickle.dump(G, f, pickle.HIGHEST_PROTOCOL) |
414 |
+ |
415 |
+- numfib_mlab = nx.to_numpy_matrix(numfib, dtype=int) |
416 |
++ numfib_mlab = nx.to_numpy_array(numfib, dtype=int) |
417 |
+ numfib_dict = {"number_of_fibers": numfib_mlab} |
418 |
+- fibmean_mlab = nx.to_numpy_matrix(fibmean, dtype=np.float64) |
419 |
++ fibmean_mlab = nx.to_numpy_array(fibmean, dtype=np.float64) |
420 |
+ fibmean_dict = {"mean_fiber_length": fibmean_mlab} |
421 |
+- fibmedian_mlab = nx.to_numpy_matrix(fibmedian, dtype=np.float64) |
422 |
++ fibmedian_mlab = nx.to_numpy_array(fibmedian, dtype=np.float64) |
423 |
+ fibmedian_dict = {"median_fiber_length": fibmedian_mlab} |
424 |
+- fibdev_mlab = nx.to_numpy_matrix(fibdev, dtype=np.float64) |
425 |
++ fibdev_mlab = nx.to_numpy_array(fibdev, dtype=np.float64) |
426 |
+ fibdev_dict = {"fiber_length_std": fibdev_mlab} |
427 |
+ |
428 |
+ if intersections: |
429 |
+diff --git a/nipype/interfaces/cmtk/nbs.py b/nipype/interfaces/cmtk/nbs.py |
430 |
+index b0a8b5df33..2560ed8e3c 100644 |
431 |
+--- a/nipype/interfaces/cmtk/nbs.py |
432 |
++++ b/nipype/interfaces/cmtk/nbs.py |
433 |
+@@ -40,7 +40,7 @@ def ntwks_to_matrices(in_files, edge_key): |
434 |
+ raise KeyError( |
435 |
+ "the graph edges do not have {} attribute".format(edge_key) |
436 |
+ ) |
437 |
+- matrix[:, :, idx] = nx.to_numpy_matrix(graph) # Retrieve the matrix |
438 |
++ matrix[:, :, idx] = nx.to_numpy_array(graph) # Retrieve the matrix |
439 |
+ return matrix |
440 |
+ |
441 |
+ |
442 |
+ |
443 |
+From f20035c303a88fba3e207ac60388397665bb97be Mon Sep 17 00:00:00 2001 |
444 |
+From: Chris Markiewicz <effigies@×××××.com> |
445 |
+Date: Sat, 28 Jan 2023 12:45:38 -0500 |
446 |
+Subject: [PATCH 8/9] FIX: Purge nx.read_gpickle |
447 |
+ |
448 |
+--- |
449 |
+ nipype/interfaces/cmtk/convert.py | 9 ++++++++- |
450 |
+ nipype/interfaces/cmtk/nbs.py | 11 ++++++++--- |
451 |
+ nipype/interfaces/cmtk/nx.py | 11 ++++++++--- |
452 |
+ 3 files changed, 24 insertions(+), 7 deletions(-) |
453 |
+ |
454 |
+diff --git a/nipype/interfaces/cmtk/convert.py b/nipype/interfaces/cmtk/convert.py |
455 |
+index 321a40fbba..a45daddcd6 100644 |
456 |
+--- a/nipype/interfaces/cmtk/convert.py |
457 |
++++ b/nipype/interfaces/cmtk/convert.py |
458 |
+@@ -18,6 +18,13 @@ |
459 |
+ from .base import CFFBaseInterface, have_cfflib |
460 |
+ |
461 |
+ |
462 |
++def _read_pickle(fname): |
463 |
++ import pickle |
464 |
++ |
465 |
++ with open(fname, 'rb') as f: |
466 |
++ return pickle.load(f) |
467 |
++ |
468 |
++ |
469 |
+ class CFFConverterInputSpec(BaseInterfaceInputSpec): |
470 |
+ graphml_networks = InputMultiPath( |
471 |
+ File(exists=True), desc="list of graphML networks" |
472 |
+@@ -135,7 +142,7 @@ def _run_interface(self, runtime): |
473 |
+ unpickled = [] |
474 |
+ for ntwk in self.inputs.gpickled_networks: |
475 |
+ _, ntwk_name, _ = split_filename(ntwk) |
476 |
+- unpickled = nx.read_gpickle(ntwk) |
477 |
++ unpickled = _read_pickle(ntwk) |
478 |
+ cnet = cf.CNetwork(name=ntwk_name) |
479 |
+ cnet.set_with_nxgraph(unpickled) |
480 |
+ a.add_connectome_network(cnet) |
481 |
+diff --git a/nipype/interfaces/cmtk/nbs.py b/nipype/interfaces/cmtk/nbs.py |
482 |
+index 2560ed8e3c..a2bd42abee 100644 |
483 |
+--- a/nipype/interfaces/cmtk/nbs.py |
484 |
++++ b/nipype/interfaces/cmtk/nbs.py |
485 |
+@@ -24,13 +24,18 @@ |
486 |
+ iflogger = logging.getLogger("nipype.interface") |
487 |
+ |
488 |
+ |
489 |
++def _read_pickle(fname): |
490 |
++ with open(fname, 'rb') as f: |
491 |
++ return pickle.load(f) |
492 |
++ |
493 |
++ |
494 |
+ def ntwks_to_matrices(in_files, edge_key): |
495 |
+- first = nx.read_gpickle(in_files[0]) |
496 |
++ first = _read_pickle(in_files[0]) |
497 |
+ files = len(in_files) |
498 |
+ nodes = len(first.nodes()) |
499 |
+ matrix = np.zeros((nodes, nodes, files)) |
500 |
+ for idx, name in enumerate(in_files): |
501 |
+- graph = nx.read_gpickle(name) |
502 |
++ graph = _read_pickle(name) |
503 |
+ for u, v, d in graph.edges(data=True): |
504 |
+ try: |
505 |
+ graph[u][v]["weight"] = d[ |
506 |
+@@ -162,7 +167,7 @@ def _run_interface(self, runtime): |
507 |
+ else: |
508 |
+ node_ntwk_name = self.inputs.in_group1[0] |
509 |
+ |
510 |
+- node_network = nx.read_gpickle(node_ntwk_name) |
511 |
++ node_network = _read_pickle(node_ntwk_name) |
512 |
+ iflogger.info( |
513 |
+ "Populating node dictionaries with attributes from %s", node_ntwk_name |
514 |
+ ) |
515 |
+diff --git a/nipype/interfaces/cmtk/nx.py b/nipype/interfaces/cmtk/nx.py |
516 |
+index a662eb65c6..991ca89dcf 100644 |
517 |
+--- a/nipype/interfaces/cmtk/nx.py |
518 |
++++ b/nipype/interfaces/cmtk/nx.py |
519 |
+@@ -24,11 +24,16 @@ |
520 |
+ iflogger = logging.getLogger("nipype.interface") |
521 |
+ |
522 |
+ |
523 |
++def _read_pickle(fname): |
524 |
++ with open(fname, 'rb') as f: |
525 |
++ return pickle.load(f) |
526 |
++ |
527 |
++ |
528 |
+ def read_unknown_ntwk(ntwk): |
529 |
+ if not isinstance(ntwk, nx.classes.graph.Graph): |
530 |
+ _, _, ext = split_filename(ntwk) |
531 |
+ if ext == ".pck": |
532 |
+- ntwk = nx.read_gpickle(ntwk) |
533 |
++ ntwk = _read_pickle(ntwk) |
534 |
+ elif ext == ".graphml": |
535 |
+ ntwk = nx.read_graphml(ntwk) |
536 |
+ return ntwk |
537 |
+@@ -121,7 +126,7 @@ def average_networks(in_files, ntwk_res_file, group_id): |
538 |
+ counting_ntwk = ntwk.copy() |
539 |
+ # Sums all the relevant variables |
540 |
+ for index, subject in enumerate(in_files): |
541 |
+- tmp = nx.read_gpickle(subject) |
542 |
++ tmp = _read_pickle(subject) |
543 |
+ iflogger.info("File %s has %i edges", subject, tmp.number_of_edges()) |
544 |
+ edges = list(tmp.edges()) |
545 |
+ for edge in edges: |
546 |
+@@ -461,7 +466,7 @@ def _run_interface(self, runtime): |
547 |
+ edgentwks = list() |
548 |
+ kntwks = list() |
549 |
+ matlab = list() |
550 |
+- ntwk = nx.read_gpickle(self.inputs.in_file) |
551 |
++ ntwk = _read_pickle(self.inputs.in_file) |
552 |
+ |
553 |
+ # Each block computes, writes, and saves a measure |
554 |
+ # The names are then added to the output .pck file list |
555 |
+ |
556 |
+From f6bf0af19c044709de5be79a4488dcfd4d08f305 Mon Sep 17 00:00:00 2001 |
557 |
+From: Chris Markiewicz <effigies@×××××.com> |
558 |
+Date: Sat, 28 Jan 2023 13:23:33 -0500 |
559 |
+Subject: [PATCH 9/9] FIX: Add dtypes to nilearn interface/tests |
560 |
+ |
561 |
+--- |
562 |
+ nipype/interfaces/nilearn.py | 2 +- |
563 |
+ nipype/interfaces/tests/test_nilearn.py | 5 +++-- |
564 |
+ 2 files changed, 4 insertions(+), 3 deletions(-) |
565 |
+ |
566 |
+diff --git a/nipype/interfaces/nilearn.py b/nipype/interfaces/nilearn.py |
567 |
+index 053902e2bd..95494e7f5f 100644 |
568 |
+--- a/nipype/interfaces/nilearn.py |
569 |
++++ b/nipype/interfaces/nilearn.py |
570 |
+@@ -155,7 +155,7 @@ def _process_inputs(self): |
571 |
+ if self.inputs.include_global: |
572 |
+ global_label_data = label_data.dataobj.sum(axis=3) # sum across all regions |
573 |
+ global_label_data = ( |
574 |
+- np.rint(global_label_data).astype(int).clip(0, 1) |
575 |
++ np.rint(global_label_data).clip(0, 1).astype('u1') |
576 |
+ ) # binarize |
577 |
+ global_label_data = self._4d(global_label_data, label_data.affine) |
578 |
+ global_masker = nl.NiftiLabelsMasker( |
579 |
+diff --git a/nipype/interfaces/tests/test_nilearn.py b/nipype/interfaces/tests/test_nilearn.py |
580 |
+index 2066c00768..4f94bbb87b 100644 |
581 |
+--- a/nipype/interfaces/tests/test_nilearn.py |
582 |
++++ b/nipype/interfaces/tests/test_nilearn.py |
583 |
+@@ -184,10 +184,11 @@ def assert_expected_output(self, labels, wanted): |
584 |
+ [[2, -2, -1, -2, -5], [3, 0, 3, -5, -2]], |
585 |
+ [[-4, -2, -2, 1, -2], [3, 1, 4, -3, -2]], |
586 |
+ ], |
587 |
+- ] |
588 |
++ ], |
589 |
++ np.int16, |
590 |
+ ) |
591 |
+ |
592 |
+- fake_label_data = np.array([[[1, 0], [3, 1]], [[2, 0], [1, 3]]]) |
593 |
++ fake_label_data = np.array([[[1, 0], [3, 1]], [[2, 0], [1, 3]]], np.uint8) |
594 |
+ |
595 |
+ fake_equiv_4d_label_data = np.array( |
596 |
+ [ |
597 |
|
598 |
diff --git a/sci-libs/nipype/nipype-1.8.4.ebuild b/sci-libs/nipype/nipype-1.8.4.ebuild |
599 |
new file mode 100644 |
600 |
index 000000000..e1172c4c5 |
601 |
--- /dev/null |
602 |
+++ b/sci-libs/nipype/nipype-1.8.4.ebuild |
603 |
@@ -0,0 +1,92 @@ |
604 |
+# Copyright 1999-2022 Gentoo Authors |
605 |
+# Distributed under the terms of the GNU General Public License v2 |
606 |
+ |
607 |
+EAPI=8 |
608 |
+ |
609 |
+PYTHON_COMPAT=( python3_10 ) |
610 |
+PYTHON_REQ_USE="threads(+),sqlite" |
611 |
+ |
612 |
+inherit distutils-r1 |
613 |
+ |
614 |
+DESCRIPTION="Neuroimaging in Python: Pipelines and Interfaces" |
615 |
+HOMEPAGE="http://nipy.sourceforge.net/nipype/" |
616 |
+SRC_URI="https://github.com/nipy/nipype/archive/${PV}.tar.gz -> ${P}.tar.gz" |
617 |
+ |
618 |
+LICENSE="BSD" |
619 |
+SLOT="0" |
620 |
+KEYWORDS="~amd64 ~x86" |
621 |
+IUSE="test" |
622 |
+RESTRICT="!test? ( test )" |
623 |
+ |
624 |
+DEPEND=" |
625 |
+ dev-python/numpy[${PYTHON_USEDEP}] |
626 |
+ dev-python/prov[${PYTHON_USEDEP}] |
627 |
+ sci-libs/nibabel[${PYTHON_USEDEP}] |
628 |
+ test? ( |
629 |
+ dev-python/mock[${PYTHON_USEDEP}] |
630 |
+ dev-python/pytest[${PYTHON_USEDEP}] |
631 |
+ ${RDEPEND} |
632 |
+ ) |
633 |
+" |
634 |
+ |
635 |
+RDEPEND=" |
636 |
+ dev-python/click[${PYTHON_USEDEP}] |
637 |
+ dev-python/rdflib[${PYTHON_USEDEP}] |
638 |
+ dev-python/filelock[${PYTHON_USEDEP}] |
639 |
+ dev-python/networkx[${PYTHON_USEDEP}] |
640 |
+ dev-python/packaging[${PYTHON_USEDEP}] |
641 |
+ dev-python/pydot[${PYTHON_USEDEP}] |
642 |
+ dev-python/python-dateutil[${PYTHON_USEDEP}] |
643 |
+ dev-python/scipy[${PYTHON_USEDEP}] |
644 |
+ dev-python/simplejson[${PYTHON_USEDEP}] |
645 |
+ <dev-python/traits-6.4.0[${PYTHON_USEDEP}] |
646 |
+" |
647 |
+ |
648 |
+PATCHES=( |
649 |
+ "${FILESDIR}/${PN}-1.8.4-dependency_compatibility.patch" |
650 |
+) |
651 |
+ |
652 |
+src_prepare() { |
653 |
+ # Remove etelemetry |
654 |
+ sed -i '/"etelemetry/d' nipype/info.py requirements.txt || die |
655 |
+ |
656 |
+ # Mark failing tests |
657 |
+ sed -i \ |
658 |
+ -e "/def test_no_et(tmp_path):/i@×××××××××××.skip('Known to fail by upstream: https://github.com/nipy/nipype/issues/3196#issuecomment-606003186')" \ |
659 |
+ nipype/tests/test_nipype.py || die |
660 |
+ sed -i \ |
661 |
+ -e "/def test_fslversion():/i@×××××××××××.skip('Known to fail by upstream: https://github.com/nipy/nipype/issues/3196#issuecomment-605997462')" \ |
662 |
+ nipype/interfaces/fsl/tests/test_base.py || die |
663 |
+ default |
664 |
+} |
665 |
+ |
666 |
+python_install_all() { |
667 |
+ distutils-r1_python_install_all |
668 |
+ doenvd "${FILESDIR}/98nipype" |
669 |
+} |
670 |
+ |
671 |
+# Reported upstream: |
672 |
+# https://github.com/nipy/nipype/issues/3540 |
673 |
+EPYTEST_DESELECT=( |
674 |
+ nipype/interfaces/tests/test_io.py::test_s3datagrabber_communication |
675 |
+) |
676 |
+ |
677 |
+python_test() { |
678 |
+ # Setting environment variable to disable etelemetry version check: |
679 |
+ # https://github.com/nipy/nipype/issues/3196#issuecomment-605980044 |
680 |
+ NIPYPE_NO_ET=1 epytest |
681 |
+ # Upstream test configuration fails |
682 |
+ #-c nipype/pytest.ini\ |
683 |
+ #--doctest-modules nipype\ |
684 |
+ #--cov nipype\ |
685 |
+ #--cov-config .coveragerc\ |
686 |
+ #--cov-report xml:cov.xml\ |
687 |
+} |
688 |
+ |
689 |
+pkg_postinst() { |
690 |
+ echo |
691 |
+ einfo "Please run the following commands if you" |
692 |
+ einfo "intend to use nipype from an existing shell:" |
693 |
+ einfo "source /etc/profile" |
694 |
+ echo |
695 |
+} |