Skip to content

Commit

Permalink
remove tests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmeunier79 committed Nov 21, 2024
1 parent 03003ae commit 5502d1d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 150 deletions.
30 changes: 0 additions & 30 deletions macapype/nodes/pad.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,36 +39,6 @@ def pad_back(seg_pipe, data_preparation_pipe, inputnode,
pad_node, "out_file",
outputnode, outputnodefile)

elif "long_single_preparation_pipe" in params.keys():
if "prep_T1" in params["long_single_preparation_pipe"].keys():

print("Padding mask in native space")
pad_node = pe.Node(
niu.Function(
input_names=[
'cropped_img_file',
'orig_img_file',
'indiv_crop'],
output_names=['padded_img_file'],
function=padding_cropped_img),
name=pad_nodename)

seg_pipe.connect(
node, nodefile,
pad_node, "cropped_img_file")

seg_pipe.connect(
data_preparation_pipe, "outputnode.native_T1",
pad_node, "orig_img_file")

seg_pipe.connect(
inputnode, "indiv_params",
pad_node, "indiv_crop")

seg_pipe.connect(
pad_node, "padded_img_file",
outputnode, outputnodefile)

return pad_node


Expand Down
21 changes: 6 additions & 15 deletions macapype/pipelines/full_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
from macapype.nodes.pad import pad_back

from .prepare import (create_short_preparation_pipe,
create_short_preparation_T1_pipe,
create_long_single_preparation_pipe,)
create_short_preparation_T1_pipe)

from .segment import (create_old_segment_pipe,
create_native_old_segment_pipe,
Expand Down Expand Up @@ -164,7 +163,7 @@ def create_full_spm_subpipes(

else:
print("Error, short_preparation_pipe, \
long_multi_preparation_pipe was not found in params, skipping")
was not found in params, skipping")

test_node = pe.Node(niu.Function(input_names=['list_T1', 'list_T2'],
output_names=[''],
Expand Down Expand Up @@ -806,11 +805,7 @@ def create_full_ants_subpipes(
Params:
- short_data_preparation_pipe (see :class:`create_short_preparation_pipe \
<macapype.pipelines.prepare.create_short_preparation_pipe>`) or \
long_single_preparation_pipe \
(see :class:`create_long_single_preparation_pipe \
<macapype.pipelines.prepare.create_long_single_preparation_pipe>`) or \
long_multi_preparation_pipe \
<macapype.pipelines.prepare.create_short_preparation_pipe>`)
- brain_extraction_pipe (see :class:`create_brain_extraction_pipe \
<macapype.pipelines.full_pipelines.create_brain_extraction_pipe>`)
Expand Down Expand Up @@ -899,18 +894,14 @@ def create_full_ants_subpipes(
name='outputnode')

# preprocessing
if 'long_single_preparation_pipe' in params.keys():
data_preparation_pipe = create_long_single_preparation_pipe(
params=parse_key(params, "long_single_preparation_pipe"))

elif 'short_preparation_pipe' in params.keys():
if 'short_preparation_pipe' in params.keys():
data_preparation_pipe = create_short_preparation_pipe(
params=parse_key(params, "short_preparation_pipe"),
params_template=params_template_stereo)

else:
print("Error, short_preparation_pipe, long_single_preparation_pipe or\
long_multi_preparation_pipe was not found in params, skipping")
print("Error, short_preparation_pipe \
was not found in params, skipping")

test_node = pe.Node(niu.Function(input_names=['list_T1', 'list_T2'],
output_names=[''],
Expand Down
4 changes: 2 additions & 2 deletions macapype/pipelines/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _create_avg_reorient_pipeline(name="avg_reorient_pipe", params={}):
return reorient_pipe

###############################################################################
# choices between the 3 main pipelines: "short", "long_single" et "long_multi"
# main pipeline: "short_preparation_pipe"
###############################################################################

def create_short_preparation_pipe(params, params_template={},
Expand Down Expand Up @@ -655,7 +655,7 @@ def create_short_preparation_T1_pipe(params, params_template,
dictionary of node sub-parameters (from a json file)
name:
pipeline name (default = "long_multi_preparation_pipe")
pipeline name (default = "short_preparation_T1_pipe")
Outputs:
Expand Down
48 changes: 1 addition & 47 deletions macapype/pipelines/tests/test_prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

from macapype.utils.utils_tests import make_tmp_dir
from macapype.utils.misc import parse_key
from macapype.pipelines.prepare import (create_short_preparation_pipe,
create_long_single_preparation_pipe)
from macapype.pipelines.prepare import create_short_preparation_pipe

data_path = make_tmp_dir()

Expand Down Expand Up @@ -61,48 +60,3 @@ def test_create_crop_T1_short_preparation_pipe():
assert op.exists(op.join(data_path,
"short_manual_preparation_pipe",
"graph.png"))


def test_create_long_single_preparation_pipe():
params = {
"long_single_preparation_pipe":
{
"prep_T1":
{
"crop_T1":
{
"args": "should be defined in indiv"
},
"denoise":
{
"shrink_factor": 1
}
},
"prep_T2":
{
"crop_T2":
{
"args": "should be defined in indiv"
},
"denoise":
{
"shrink_factor": 1
}
},
"align_T2_on_T1":
{
}
}
}

# running workflow
segment_pnh = create_long_single_preparation_pipe(
params=parse_key(params, "long_single_preparation_pipe"),
name="long_single_preparation_pipe")

segment_pnh.base_dir = data_path

segment_pnh.write_graph(graph2use="colored")
assert op.exists(op.join(data_path,
"long_single_preparation_pipe",
"graph.png"))
58 changes: 2 additions & 56 deletions macapype/utils/utils_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,44 +82,11 @@ def update_preparation_params(ssoft=[], subjects=None, sessions=None,
if "crop_T1" in indiv.keys():
count_T1_crops += 1

if "crop_T2" in indiv.keys() and 't1' not in ssoft:

count_long_crops += 1

crop_T1_args = indiv["crop_T1"]["args"]
crop_T2_args = indiv["crop_T2"]["args"]
if isinstance(crop_T1_args, list) and \
isinstance(crop_T2_args, list):

count_multi_long_crops += 1

print("count_all_sessions {}".format(count_all_sessions))
print("count_T1_crops {}".format(count_T1_crops))
print("count_long_crops {}".format(count_long_crops))
print("count_multi_long_crops {}".format(
count_multi_long_crops))

if count_all_sessions:
if count_multi_long_crops == count_all_sessions:
print("**** Found list of crops for T1 and T2\
for all sub/ses in indiv -> \
long_multi_preparation_pipe")

prep_pipe = "long_multi_preparation_pipe"

extra_wf_name += "_indiv_crop_long_multi"

elif count_long_crops == count_all_sessions:

print("**** Found crop for T1 and crop for T2\
for all sub/ses in indiv -> \
long_single_preparation_pipe")

prep_pipe = "long_single_preparation_pipe"

extra_wf_name += "_indiv_crop_long_single"

elif count_T1_crops == count_all_sessions:
if count_T1_crops == count_all_sessions:

print("**** Found crop for T1 for all \
sub/ses in indiv \
Expand All @@ -128,7 +95,7 @@ def update_preparation_params(ssoft=[], subjects=None, sessions=None,
extra_wf_name += "_indiv_crop"

else:
print("**** not all sub/ses have T1 and T2 crops,\
print("**** not all sub/ses have T1 crops,\
using autocrop ")

extra_wf_name += "_crop_aladin"
Expand Down Expand Up @@ -179,27 +146,6 @@ def update_preparation_params(ssoft=[], subjects=None, sessions=None,
print("Adding crop_T1")
params["short_preparation_pipe"]["crop_T1"] = \
{"args": "should be defined in indiv"}
else:
print("modifying prep = {}".format(prep_pipe))

params[prep_pipe] = {
"prep_T1": {
"crop_T1": {
"args": "should be defined in indiv"}
},
"prep_T2": {
"crop_T2": {
"args": "should be defined in indiv"}
}
}

if "denoise" in params["short_preparation_pipe"].keys():
denoise = params["short_preparation_pipe"]["denoise"]

params[prep_pipe]["prep_T1"]["denoise"] = denoise
params[prep_pipe]["prep_T2"]["denoise"] = denoise

del params["short_preparation_pipe"]

return params, indiv_params, extra_wf_name

Expand Down

0 comments on commit 5502d1d

Please sign in to comment.