Skip to content

Commit 609a0e6

Browse files
authored
Merge pull request #437 from dPys/development
Development
2 parents 8108852 + aaf48e1 commit 609a0e6

29 files changed

+2024
-1206
lines changed

pynets/__about__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
# from ._version import get_versions
77
# __version__ = get_versions()['version']
88
# del get_versions
9-
__version__ = "1.0.13"
9+
__version__ = "1.0.14"
1010

1111
__packagename__ = "pynets"
12-
__copyright__ = "Copyright 2017, Derek Pisner"
12+
__copyright__ = "Copyright 2016, Derek Pisner"
1313
__credits__ = (
1414
"Contributors: please check the ``.zenodo.json`` file at the top-level folder"
1515
"of the repository")

pynets/cli/pynets_cloud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
"""
44
Created on Tue Nov 7 10:40:07 2017
5-
Copyright (C) 2017
5+
Copyright (C) 2016
66
@author: Derek Pisner (dPys)
77
"""
88
import subprocess

pynets/cli/pynets_collect.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
"""
44
Created on Tue Nov 7 10:40:07 2017
5-
Copyright (C) 2017
5+
Copyright (C) 2016
66
@author: Derek Pisner (dPys)
77
"""
88
from nipype.interfaces import utility as niu
@@ -915,8 +915,9 @@ def main():
915915
args_dict_all['plug'] = 'MultiProc'
916916
args_dict_all['v'] = False
917917
args_dict_all['pm'] = '24,57'
918-
args_dict_all['basedir'] = '/working/tuning_set/outputs_shaeffer/pynets'
918+
#args_dict_all['basedir'] = '/working/tuning_set/outputs_shaeffer/pynets'
919919
#args_dict_all['basedir'] = '/scratch/04171/dpisner/HNU/HNU_outs/triple/pynets'
920+
args_dict_all['basedir'] = '/scratch/04171/dpisner/HNU/HNU_outs/visual/pynets'
920921
args_dict_all['work'] = '/tmp/work/dwi'
921922
args_dict_all['modality'] = 'dwi'
922923
args_dict_all['dc'] = ['diversity_coefficient',
@@ -926,7 +927,8 @@ def main():
926927
'average_local_clustering_nodewise',
927928
'average_local_efficiency_nodewise',
928929
'degree_centrality',
929-
"_minlength-0",
930+
'weighted_transitivity',
931+
# "_minlength-0",
930932
"_minlength-20", "_minlength-30", "variance",
931933
"res-1000"]
932934
args = SimpleNamespace(**args_dict_all)

pynets/cli/pynets_run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
"""
44
Created on Tue Nov 7 10:40:07 2017
5-
Copyright (C) 2017
5+
Copyright (C) 2016
66
@author: Derek Pisner (dPys)
77
"""
88
import warnings

pynets/core/cloud_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
"""
44
Created on Tue Nov 7 10:40:07 2017
5-
Copyright (C) 2017
5+
Copyright (C) 2016
66
@author: Derek Pisner (dPys)
77
"""
88
from configparser import ConfigParser

pynets/core/interfaces.py

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding: utf-8 -*-
33
"""
44
Created on Fri Nov 10 15:44:46 2017
5-
Copyright (C) 2017
5+
Copyright (C) 2016
66
@author: Derek Pisner (dPys)
77
"""
88
import warnings
@@ -107,9 +107,14 @@ def _run_interface(self, runtime):
107107
else:
108108
parcel_list = None
109109
else:
110-
raise FileNotFoundError(
111-
f"\nAtlas file for {self.inputs.atlas} not found!"
112-
)
110+
try:
111+
raise FileNotFoundError(
112+
f"\nAtlas file for {self.inputs.atlas} not found!"
113+
)
114+
except FileNotFoundError:
115+
import sys
116+
sys.exit(0)
117+
113118
atlas = self.inputs.atlas
114119
elif (
115120
self.inputs.uatlas is None
@@ -159,8 +164,12 @@ def _run_interface(self, runtime):
159164
else:
160165
parcel_list = None
161166
else:
162-
raise ValueError(
163-
f"\nAtlas file for {self.inputs.atlas} not found!")
167+
try:
168+
raise FileNotFoundError(
169+
f"\nAtlas file for {self.inputs.atlas} not found!")
170+
except FileNotFoundError:
171+
import sys
172+
sys.exit(0)
164173
par_max = None
165174
atlas = self.inputs.atlas
166175
label_intensities = None
@@ -194,14 +203,12 @@ def _run_interface(self, runtime):
194203
# Describe user atlas coords
195204
print(f"\n{self.inputs.atlas} comes with {par_max} parcels\n")
196205
except ValueError:
206+
import sys
197207
print(
198208
"Either you have specified the name of an atlas that does"
199209
" not exist in the nilearn or local repository or you have"
200210
" not supplied a 3d atlas parcellation image!")
201-
parcel_list = None
202-
par_max = None
203-
coords = None
204-
label_intensities = None
211+
sys.exit(0)
205212
labels = None
206213
networks_list = None
207214
atlas = self.inputs.atlas
@@ -242,24 +249,23 @@ def _run_interface(self, runtime):
242249
# Describe user atlas coords
243250
print(f"\n{atlas} comes with {par_max} parcels\n")
244251
except ValueError:
252+
import sys
245253
print(
246254
"Either you have specified the name of an atlas that does"
247255
" not exist in the nilearn or local repository or you have"
248256
" not supplied a 3d atlas parcellation image!")
249-
parcel_list = None
250-
par_max = None
251-
coords = None
252-
atlas = None
253-
uatlas = None
254-
label_intensities = None
257+
sys.exit(0)
255258
labels = None
256259
networks_list = None
257260
else:
258-
raise ValueError(
259-
"Either you have specified the name of an atlas that does not"
260-
" exist in the nilearn or local repository or you have not"
261-
" supplied a 3d atlas parcellation image!")
262-
261+
try:
262+
raise ValueError(
263+
"Either you have specified the name of an atlas that does"
264+
" not exist in the nilearn or local repository or you have"
265+
" not supplied a 3d atlas parcellation image!")
266+
except ValueError:
267+
import sys
268+
sys.exit(0)
263269
# Labels prep
264270
if atlas and not labels:
265271
if (self.inputs.ref_txt is not None) and (
@@ -748,11 +754,15 @@ def run_bs_iteration(i, ts_data, work_dir, local_corr,
748754
parcellation.to_filename(out_path)
749755

750756
else:
751-
raise ValueError(
752-
"Clustering method not recognized. See: "
753-
"https://nilearn.github.io/modules/generated/"
754-
"nilearn.regions.Parcellations."
755-
"html#nilearn.regions.Parcellations")
757+
try:
758+
raise ValueError(
759+
"Clustering method not recognized. See: "
760+
"https://nilearn.github.io/modules/generated/"
761+
"nilearn.regions.Parcellations."
762+
"html#nilearn.regions.Parcellations")
763+
except ValueError:
764+
import sys
765+
sys.exit(0)
756766

757767
# Give it a minute
758768
ix = 0
@@ -762,8 +772,12 @@ def run_bs_iteration(i, ts_data, work_dir, local_corr,
762772
ix += 1
763773

764774
if not os.path.isfile(nip.uatlas):
765-
raise FileNotFoundError(f"Parcellation clustering failed for"
766-
f" {nip.uatlas}")
775+
try:
776+
raise FileNotFoundError(f"Parcellation clustering failed for"
777+
f" {nip.uatlas}")
778+
except FileNotFoundError:
779+
import sys
780+
sys.exit(0)
767781

768782
self._results["atlas"] = atlas
769783
self._results["uatlas"] = nip.uatlas
@@ -918,6 +932,7 @@ def _run_interface(self, runtime):
918932
== te.ts_within_nodes.shape[1]
919933
)
920934
except AssertionError as e:
935+
import sys
921936
e.args += ('Coords: ', len(self.inputs.coords),
922937
self.inputs.coords, 'Labels:',
923938
len(self.inputs.labels),
@@ -2293,8 +2308,10 @@ def _run_interface(self, runtime):
22932308
self.inputs.labels)
22942309

22952310
except FileNotFoundError:
2311+
import sys
22962312
print('T1w-space parcellation not found. Did you delete '
22972313
'outputs?')
2314+
sys.exit(0)
22982315
else:
22992316
if self.inputs.uatlas is None:
23002317
uatlas_tmp_path = None
@@ -2455,10 +2472,12 @@ def _run_interface(self, runtime):
24552472
try:
24562473
assert len(coords) == len(labels) == len(intensities)
24572474
except ValueError as err:
2475+
import sys
24582476
print('Failed!')
24592477
print(f"# Coords: {len(coords)}")
24602478
print(f"# Labels: {len(labels)}")
24612479
print(f"# Intensities: {len(intensities)}")
2480+
sys.exit(1)
24622481

24632482
self._results["aligned_atlas_gm"] = aligned_atlas_gm
24642483
self._results["coords"] = coords
@@ -2664,6 +2683,7 @@ class _TrackingOutputSpec(TraitedSpec):
26642683
min_length = traits.Any()
26652684
error_margin = traits.Any()
26662685

2686+
26672687
class Tracking(SimpleInterface):
26682688
"""Interface wrapper for Tracking"""
26692689

@@ -2921,7 +2941,12 @@ def _run_interface(self, runtime):
29212941
f" Maximum"
29222942
)
29232943
else:
2924-
raise ValueError("Direction-getting type not recognized!")
2944+
try:
2945+
raise ValueError("Direction-getting type not recognized!")
2946+
except ValueError:
2947+
import sys
2948+
sys.exit(0)
2949+
29252950
print(Style.RESET_ALL)
29262951

29272952
# Commence Ensemble Tractography
@@ -3010,8 +3035,12 @@ def _run_interface(self, runtime):
30103035
f"streamlines output {namer_dir}/{op.basename(streams)}"
30113036
f" is recommended.")
30123037
if len(streamlines) < 0.5*orig_count:
3013-
raise ValueError('LiFE revealed no plausible streamlines in '
3014-
'the tractogram!')
3038+
try:
3039+
raise ValueError('LiFE revealed no plausible streamlines '
3040+
'in the tractogram!')
3041+
except ValueError:
3042+
import sys
3043+
sys.exit(0)
30153044
del dwi_data, mask_data
30163045

30173046
stf = StatefulTractogram(

0 commit comments

Comments
 (0)