Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import os, glob, sys
#where are we
if "datadir" not in config.keys():
JOBDIR=os.path.abspath(os.path.curdir)
else:
if os.path.isdir(config['datadir']):
JOBDIR=config['datadir']
else:
print("given data dir does not exist {data}".format(data=config['datadir']))
sys.exit(1)
if JOBDIR[-1] != "/":
JOBDIR+="/"
datasets = glob.glob('*00.h5')
#data specific config file
configfile: "tomancak.json"
def produce_string(_fstring, *args, **kwargs):
contents = dict()
for item in args:
if type(item) == type(kwargs):
contents.update(item)
contents.update(kwargs)
return _fstring.format(**contents)
rule done:
input: [ ds+"-deconvolved" for ds in datasets ]
rule registration:
input: "{xml_base}-{file_id,\d+}-00.h5"
output: "{xml_base}-{file_id,\d+}-00.h5_registered", #convenience files
"{xml_base}.job_{file_id,\d+}.xml"
log: "{xml_base}-{file_id,\d+}-registration.log"
run:
cmd_string = produce_string(
"""{fiji-prefix} {fiji-app} \
-Dparallel_timepoints={file_id_w} \
-Dimage_file_directory={jdir} \
-Dxml_filename={input_xml} \
-Dprocess_timepoint={timepoint} \
-Dprocess_channel={channel} \
-Dprocess_illumination={illuminations} \
-Dprocess_angle={angle} \
-Dprocessing_channel={proc-ch} \
-Dlabel_interest_points={label_interest_points} \
-Dtype_of_registration={type_of_registration} \
-Dtype_of_detection={type_of_detection} \
-Dsubpixel_localization={subpixel_localization} \
-Dimglib_container={imglib_container} \
-Dradius_1={radius_1} \
-Dradius_2={radius_2} \
-Dthreshold={threshold} \
-Dinitial_sigma={initial_sigma} \
-Dthreshold_gaussian={threshold_gaussian} \
-Dregistration_algorithm={algorithm} \
-Dinterest_points_channel_0={interest_points_channel_0} \
-Dinterest_points_channel_1={interest_points_channel_1} \
-Dfix_tiles={fix_tiles} \
-Dmap_back_tiles={map_back_tiles} \
-Dtransformation_model={transformation_model} \
-Dmodel_to_regularize_with={model_to_regularize_with} \
-Dlambda={lambda} \
-Dallowed_error_for_ransac={allowed_error_for_ransac} \
-Ddetection_min_max={detection_min_max} \
-- --no-splash {bsh_file}""",
config["common"],
config["registration"],
file_id_w="{wildcards.file_id}",
jdir=JOBDIR,
input_xml="{wildcards.xml_base}")
cmd_string += "> {log} 2>&1 && touch {output}"
shell(cmd_string)
#shell("touch {output}")
rule xml_merge:
input: [ item+"_registered" for item in datasets ]
output: "{xml_base}_merge.xml"
log: "{xml_base}_merge.log"
run:
cmd_string = produce_string("{fiji-prefix} {fiji-app} -Dimage_file_directory={jdir} -Dmerged_xml={merged_xml} -- --no-splash {bsh_file} > {log} 2>&1",
config["common"],
config["xml_merge"],
log="{log}",
jdir=JOBDIR)
shell(cmd_string)
rule external_trafo:
input: rules.xml_merge.output
output: rules.xml_merge.output[0] + "_external_trafo"
log: "external_trafo.log"
# message: "etrafo {input} -> {output}"
run:
cmd_string = produce_string("""{fiji-prefix} {fiji-app} \
-Dimage_file_directory={jdir} \
-Dmerged_xml={merged_xml} \
-Dtransform_angle={angle} \
-Dtransform_channel={channel} \
-Dtransform_illumination={illumination} \
-Dtransform_timepoint={timepoint} \
-Dtransformation={transformation} \
-Dapply_transformation={apply_transformation} \
-Ddefine_mode_transform={define_mode_transform} \
-Dmatrix_transform={matrix_transform} \
-- --no-splash {bsh_file}""",
config["common"],
config["external_transform"],
jdir=JOBDIR)
cmd_string += "> {log} 2>&1 && touch {output}"
shell(cmd_string)
rule deconvolution:
input: rules.external_trafo.output, "{xml_base}-{file_id,\d+}-00.h5"
output: "{xml_base}-{file_id,\d+}-00.h5-deconvolved"
log: "{xml_base}-{file_id,\d+}-00.h5-deconvolution.log"
run:
cmd_string = produce_string("""{fiji-prefix} {fiji-app} \
-Dimage_file_directory={jdir} \
-Ddeco_output_file_directory={jdir} \
-Dmerged_xml={merged_xml} \
-Dparallel_timepoints={file_id_w} \
-Dprocess_timepoint={process_timepoint} \
-Dprocess_channel={process_channel} \
-Dprocess_illumination={process_illumination} \
-Dprocess_angle={process_angle} \
-Dminimal_x_deco={minimal_x} \
-Dminimal_y_deco={minimal_y} \
-Dminimal_z_deco={minimal_z} \
-Dmaximal_x_deco={maximal_x} \
-Dmaximal_y_deco={maximal_y} \
-Dmaximal_z_deco={maximal_z} \
-Dimglib2_container_deco={imglib2_container} \
-Dtype_of_iteration={type_of_iteration} \
-Dosem_acceleration={osem_acceleration} \
-DTikhonov_parameter={Tikhonov_parameter} \
-Dcompute={compute} \
-Dpsf_estimation={psf_estimation} \
-Ddirectory_cuda={directory_cuda} \
-Ddetections_to_extract_psf_for_channel_0={detections_to_extract_psf_for_channel_0} \
-Ddetections_to_extract_psf_for_channel_1={detections_to_extract_psf_for_channel_1} \
-Dpsf_size_x={psf_size_x} \
-Dpsf_size_y={psf_size_y} \
-Dpsf_size_z={psf_size_z} \
-Diterations={iterations} \
-- --no-splash {bsh_file}""",
config["common"],
config["deconvolution"],
file_id_w="{wildcards.file_id}",
jdir=JOBDIR)
cmd_string += "> {log} 2>&1 && touch {output}"
shell(cmd_string)
rule clean:
shell : "rm -rf *registered"