Skip to content

Commit 8958a76

Browse files
author
dPys
committed
Update tutorial version
1 parent a6910af commit 8958a76

File tree

6 files changed

+26400
-7659
lines changed

6 files changed

+26400
-7659
lines changed

pynets/cli/pynets_run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,7 +3168,7 @@ def wf_multi_subject(
31683168
shutil.rmtree(cnfnd_tmp_dir)
31693169
shutil.rmtree(f"{dir}/reg_fmri", ignore_errors=True)
31703170
for file_ in [i for i in glob.glob(
3171-
f"{dir}/*/*") if os.path.isfile(i)]:
3171+
f"{dir}/func/*") if os.path.isfile(i)]:
31723172
if ("reor-RAS" in file_) or ("res-" in file_):
31733173
try:
31743174
os.remove(file_)
@@ -3178,7 +3178,7 @@ def wf_multi_subject(
31783178
shutil.rmtree(f"{dir}/dmri_tmp", ignore_errors=True)
31793179
shutil.rmtree(f"{dir}/reg_dmri", ignore_errors=True)
31803180
for file_ in [i for i in glob.glob(
3181-
f"{dir}/*/*") if os.path.isfile(i)]:
3181+
f"{dir}/dwi/*") if os.path.isfile(i)]:
31823182
if ("reor-RAS" in file_) or ("res-" in file_):
31833183
try:
31843184
os.remove(file_)
@@ -3366,15 +3366,15 @@ def wf_multi_subject(
33663366
print("Cleaning up...")
33673367
if func_file:
33683368
for file_ in [i for i in glob.glob(
3369-
f"{subj_dir}/*/*") if os.path.isfile(i)]:
3369+
f"{subj_dir}/func/*") if os.path.isfile(i)]:
33703370
if ("reor-RAS" in file_) or ("res-" in file_):
33713371
try:
33723372
os.remove(file_)
33733373
except BaseException:
33743374
continue
33753375
if dwi_file:
33763376
for file_ in [i for i in glob.glob(
3377-
f"{subj_dir}/*/*") if os.path.isfile(i)]:
3377+
f"{subj_dir}/dwi/*") if os.path.isfile(i)]:
33783378
if ("reor-RAS" in file_) or ("res-" in file_) or \
33793379
("_bvecs_reor.bvec" in file_):
33803380
try:

pynets/core/interfaces.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,8 @@ def _run_interface(self, runtime):
11951195
copy=True,
11961196
use_hardlink=False)
11971197
else:
1198-
if len(anat_mask_existing) > 0 and self.inputs.mask is None:
1198+
if len(anat_mask_existing) > 0 and \
1199+
self.inputs.mask is None and op.isfile(anat_mask_existing[0]):
11991200
mask_tmp_path = fname_presuffix(
12001201
anat_mask_existing[0], suffix="_tmp", newpath=runtime.cwd
12011202
)
@@ -1204,9 +1205,6 @@ def _run_interface(self, runtime):
12041205
mask_tmp_path,
12051206
copy=True,
12061207
use_hardlink=False)
1207-
mask_tmp_path = regutils.check_orient_and_dims(
1208-
mask_tmp_path, runtime.cwd,
1209-
self.inputs.vox_size)
12101208
else:
12111209
mask_tmp_path = None
12121210

@@ -1912,6 +1910,7 @@ class RegisterFunc(SimpleInterface):
19121910
def _run_interface(self, runtime):
19131911
import gc
19141912
import glob
1913+
import os.path as op
19151914
from pynets.registration import register
19161915
from pynets.registration import reg_utils as regutils
19171916
from nipype.utils.filemanip import fname_presuffix, copyfile
@@ -1935,7 +1934,8 @@ def _run_interface(self, runtime):
19351934
copy=True,
19361935
use_hardlink=False)
19371936
else:
1938-
if len(anat_mask_existing) > 0 and self.inputs.mask is None:
1937+
if len(anat_mask_existing) > 0 and \
1938+
self.inputs.mask is None and op.isfile(anat_mask_existing[0]):
19391939
mask_tmp_path = fname_presuffix(
19401940
anat_mask_existing[0], suffix="_tmp",
19411941
newpath=runtime.cwd
@@ -1945,9 +1945,6 @@ def _run_interface(self, runtime):
19451945
mask_tmp_path,
19461946
copy=True,
19471947
use_hardlink=False)
1948-
mask_tmp_path = regutils.check_orient_and_dims(
1949-
mask_tmp_path, self.inputs.in_dir,
1950-
self.inputs.vox_size)
19511948
else:
19521949
mask_tmp_path = None
19531950

pynets/fmri/estimation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ def get_conn_matrix(
184184
):
185185
# Fit estimator to matrix to get sparse matrix
186186
estimator_shrunk = None
187-
estimator = GraphicalLassoCV(cv=5, max_iter=200)
187+
estimator = GraphicalLassoCV(cv=5, max_iter=200,
188+
assume_centered=True)
188189
print("\nComputing covariance...\n")
189190
try:
190191
estimator.fit(time_series)
@@ -197,6 +198,7 @@ def get_conn_matrix(
197198
for tol in [0.000001, 0.00001, 0.001, 0.01, 0.1, 1, 10]:
198199
try:
199200
estimator = GraphicalLassoCV(cv=5, max_iter=200,
201+
assume_centered=True,
200202
tol=tol, mode='lars')
201203
estimator.fit(time_series)
202204
except BaseException:

pynets/registration/reg_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def gen_mask(t1w_head, t1w_brain, mask):
4444
t1w_brain_mask = deep_skull_strip(t1w_data, t1w_brain_mask, img)
4545
except RuntimeError:
4646
print('Deepbrain extraction failed...')
47+
del t1w_data
4748

4849
# Threshold T1w brain to binary in anat space
4950
t_img = nib.load(t1w_brain_mask)

pynets/runconfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tracking:
1919
- True
2020
tracking_method: # a tracking algorithm for dmri connectome estimation. Options are: local and particle.
2121
- 'particle'
22-
tracking_samples: # Indicates the number of cumulative streamline samples for each tractogram. *Note that we should keep this relatively low since total streamlines will actually sum cumulatively across a given connectome ensemble (e.g. 100 connectomes x 20,000 = 2 million streamlines)
22+
tracking_samples: # Indicates the number of cumulative streamline samples for each tractogram. *Note that we should keep this relatively low since total streamlines will actually sum cumulatively across a given connectome ensemble (e.g. 100 connectomes x 50,000 = 5 million streamlines!)
2323
- 50000
2424
DSN: # Experimental option. Direct Streamline Normalization attempts to normalize streamlines (i.e. post-reconstruction) to a morphologically standardized scaling (i.e. range of fiber lengths) specific to the template used. This may help to facilitate group/population analysis.
2525
- False

0 commit comments

Comments
 (0)