3838MULTI_MULTI_FILE = "[YES (one file per %s)]"
3939"""@private"""
4040
41+
4142class ProcessingOptions (object ):
4243 """Helper to store processing options and generate parameter strings.
4344
@@ -140,9 +141,7 @@ def reference_channel(self, value):
140141 """
141142 # channel = int(value) - 1 # will raise a ValueError if cast fails
142143 self ._use_channel = "channels=[use Channel %s]" % int (value )
143- log .debug (
144- "New reference channel setting: %s" , self ._use_channel
145- )
144+ log .debug ("New reference channel setting: %s" , self ._use_channel )
146145
147146 def reference_illumination (self , value ):
148147 """Set the reference illumination when using *Expert Grouping Options*.
@@ -158,9 +157,7 @@ def reference_illumination(self, value):
158157 value : int or int-like
159158 The illumination number to use for the grouping.
160159 """
161- self ._use_illumination = (
162- "illuminations=[use Illumination %s]" % value
163- )
160+ self ._use_illumination = "illuminations=[use Illumination %s]" % value
164161 log .debug (
165162 "New reference illumination setting: %s" ,
166163 self ._use_illumination ,
@@ -198,9 +195,7 @@ def reference_timepoint(self, value):
198195 The timepoint number to use for the grouping.
199196 """
200197 self ._use_timepoint = "timepoints=[use Timepoint %s]" % value
201- log .debug (
202- "New reference timepoint setting: %s" , self ._use_timepoint
203- )
198+ log .debug ("New reference timepoint setting: %s" , self ._use_timepoint )
204199
205200 ### process-X methods
206201
@@ -422,22 +417,16 @@ def fmt_acitt_options(self, input="process"):
422417 """
423418 input_type = ["process" , "resave" ]
424419 if input not in input_type :
425- raise ValueError (
426- "Invalue input type. Expected one of: %s" % input_type
427- )
420+ raise ValueError ("Invalid input type, expected one of: %s" % input_type )
428421 parameters = [
429422 input + "_angle=" + self ._angle_processing_option ,
430423 input + "_channel=" + self ._channel_processing_option ,
431- input
432- + "_illumination="
433- + self ._illumination_processing_option ,
424+ input + "_illumination=" + self ._illumination_processing_option ,
434425 input + "_tile=" + self ._tile_processing_option ,
435426 input + "_timepoint=" + self ._timepoint_processing_option ,
436427 ]
437428 parameter_string = " " .join (parameters ).strip ()
438- log .debug (
439- "Formatted 'process_X' options: <%s>" , parameter_string
440- )
429+ log .debug ("Formatted 'process_X' options: <%s>" , parameter_string )
441430 return parameter_string + " "
442431
443432 def fmt_acitt_selectors (self ):
@@ -457,16 +446,12 @@ def fmt_acitt_selectors(self):
457446 parameters = [
458447 self ._angle_select if self ._angle_select else "" ,
459448 self ._channel_select if self ._channel_select else "" ,
460- self ._illumination_select
461- if self ._illumination_select
462- else "" ,
449+ self ._illumination_select if self ._illumination_select else "" ,
463450 self ._tile_select if self ._tile_select else "" ,
464451 self ._timepoint_select if self ._timepoint_select else "" ,
465452 ]
466453 parameter_string = " " .join (parameters ).strip ()
467- log .debug (
468- "Formatted 'processing_X' selectors: <%s>" , parameter_string
469- )
454+ log .debug ("Formatted 'processing_X' selectors: <%s>" , parameter_string )
470455 return parameter_string + " "
471456
472457 def fmt_how_to_treat (self ):
@@ -484,9 +469,7 @@ def fmt_how_to_treat(self):
484469 "how_to_treat_timepoints=" + self ._treat_timepoints ,
485470 ]
486471 parameter_string = " " .join (parameters ).strip ()
487- log .debug (
488- "Formatted 'how_to_treat_X' options: <%s>" , parameter_string
489- )
472+ log .debug ("Formatted 'how_to_treat_X' options: <%s>" , parameter_string )
490473 return parameter_string + " "
491474
492475 def fmt_use_acitt (self ):
@@ -501,16 +484,10 @@ def fmt_use_acitt(self):
501484 """
502485 parameters = [
503486 self ._use_angle if self ._treat_angles == "group" else "" ,
504- self ._use_channel
505- if self ._treat_channels == "group"
506- else "" ,
507- self ._use_illumination
508- if self ._treat_illuminations == "group"
509- else "" ,
487+ self ._use_channel if self ._treat_channels == "group" else "" ,
488+ self ._use_illumination if self ._treat_illuminations == "group" else "" ,
510489 self ._use_tile if self ._treat_tiles == "group" else "" ,
511- self ._use_timepoint
512- if self ._treat_timepoints == "group"
513- else "" ,
490+ self ._use_timepoint if self ._treat_timepoints == "group" else "" ,
514491 ]
515492 parameter_string = " " .join (parameters ).strip ()
516493 log .debug (
@@ -543,9 +520,7 @@ class DefinitionOptions(object):
543520 def __init__ (self ):
544521 self ._angle_definition = SINGLE_FILE % "angle"
545522 self ._channel_definition = MULTI_SINGLE_FILE % "channel"
546- self ._illumination_definition = (
547- SINGLE_FILE % "illumination direction"
548- )
523+ self ._illumination_definition = SINGLE_FILE % "illumination direction"
549524 self ._tile_definition = MULTI_MULTI_FILE % "tile"
550525 self ._timepoint_definition = SINGLE_FILE % "time-point"
551526
@@ -611,9 +586,7 @@ def set_angle_definition(self, value):
611586 """
612587 choices = self .check_definition_option_ang_ill (value )
613588 self ._angle_definition = choices [value ] % "angle"
614- log .debug (
615- "New 'angle_definition' setting: %s" , self ._angle_definition
616- )
589+ log .debug ("New 'angle_definition' setting: %s" , self ._angle_definition )
617590
618591 def set_channel_definition (self , value ):
619592 """Set the value for the channel definition.
@@ -639,9 +612,7 @@ def set_illumination_definition(self, value):
639612 One of `single`, `multi_single` or `multi_multi`.
640613 """
641614 choices = self .check_definition_option_ang_ill (value )
642- self ._illumination_definition = (
643- choices [value ] % "illumination direction"
644- )
615+ self ._illumination_definition = choices [value ] % "illumination direction"
645616 log .debug (
646617 "New 'illumination_definition' setting: %s" ,
647618 self ._illumination_definition ,
@@ -657,9 +628,7 @@ def set_tile_definition(self, value):
657628 """
658629 choices = self .check_definition_option (value )
659630 self ._tile_definition = choices [value ] % "tile"
660- log .debug (
661- "New 'tile_definition' setting: %s" , self ._tile_definition
662- )
631+ log .debug ("New 'tile_definition' setting: %s" , self ._tile_definition )
663632
664633 def set_timepoint_definition (self , value ):
665634 """Set the value for the time_point_definition.
@@ -691,15 +660,12 @@ def fmt_acitt_options(self):
691660 parameters = [
692661 "multiple_angles=" + self ._angle_definition ,
693662 "multiple_channels=" + self ._channel_definition ,
694- "multiple_illuminations_directions="
695- + self ._illumination_definition ,
663+ "multiple_illuminations_directions=" + self ._illumination_definition ,
696664 "multiple_tiles=" + self ._tile_definition ,
697665 "multiple_timepoints=" + self ._timepoint_definition ,
698666 ]
699667 parameter_string = " " .join (parameters ).strip ()
700- log .debug (
701- "Formatted 'multiple_X' options: <%s>" , parameter_string
702- )
668+ log .debug ("Formatted 'multiple_X' options: <%s>" , parameter_string )
703669 return parameter_string + " "
704670
705671
@@ -725,9 +691,7 @@ def check_processing_input(value, range_end):
725691 value = [value ]
726692 # Check if all the elements of the value list are of the same type
727693 if not all (isinstance (x , type (value [0 ])) for x in value ):
728- raise TypeError (
729- "Invalid input type. All the values should be of the same type"
730- )
694+ raise TypeError ("Invalid input, all values must be of the same type." )
731695 if type (range_end ) is int :
732696 if type (value [0 ]) is not int :
733697 raise TypeError ("Range start needs to be an int." )
@@ -771,13 +735,7 @@ def get_processing_settings(dimension, selection, value, range_end):
771735
772736 if selection == "single" :
773737 processing_option = SINGLE % dimension
774- dimension_select = (
775- "processing_"
776- + dimension
777- + "=["
778- + dimension
779- + " %s]" % value
780- )
738+ dimension_select = "processing_" + dimension + "=[" + dimension + " %s]" % value
781739
782740 if selection == "multiple" :
783741 processing_option = MULTIPLE % dimension
@@ -820,9 +778,7 @@ def backup_xml_files(source_directory, subfolder_name):
820778 pathtools .create_directory (xml_backup_directory )
821779 backup_subfolder = xml_backup_directory + "/%s" % (subfolder_name )
822780 pathtools .create_directory (backup_subfolder )
823- all_xml_files = pathtools .listdir_matching (
824- source_directory , ".*\\ .xml" , regex = True
825- )
781+ all_xml_files = pathtools .listdir_matching (source_directory , ".*\\ .xml" , regex = True )
826782 os .chdir (source_directory )
827783 for xml_file in all_xml_files :
828784 shutil .copy2 (xml_file , backup_subfolder )
@@ -882,9 +838,7 @@ def define_dataset_auto(
882838 dataset_save_path = result_folder
883839 if subsampling_factors :
884840 subsampling_factors = (
885- "manual_mipmap_setup subsampling_factors="
886- + subsampling_factors
887- + " "
841+ "manual_mipmap_setup subsampling_factors=" + subsampling_factors + " "
888842 )
889843 else :
890844 subsampling_factors = ""
@@ -1051,9 +1005,7 @@ def resave_as_h5(
10511005 split_hdf5 = ""
10521006
10531007 if subsampling_factors :
1054- subsampling_factors = (
1055- "subsampling_factors=" + subsampling_factors + " "
1056- )
1008+ subsampling_factors = "subsampling_factors=" + subsampling_factors + " "
10571009 else :
10581010 subsampling_factors = " "
10591011 if hdf5_chunk_sizes :
@@ -1143,13 +1095,10 @@ def phase_correlation_pairwise_shifts_calculation(
11431095 file_info = pathtools .parse_path (project_path )
11441096
11451097 if downsampling_xyz != "" :
1146- downsampling = (
1147- "downsample_in_x=%s downsample_in_y=%s downsample_in_z=%s "
1148- % (
1149- downsampling_xyz [0 ],
1150- downsampling_xyz [1 ],
1151- downsampling_xyz [2 ],
1152- )
1098+ downsampling = "downsample_in_x=%s downsample_in_y=%s downsample_in_z=%s " % (
1099+ downsampling_xyz [0 ],
1100+ downsampling_xyz [1 ],
1101+ downsampling_xyz [2 ],
11531102 )
11541103 else :
11551104 downsampling = ""
@@ -1173,9 +1122,7 @@ def phase_correlation_pairwise_shifts_calculation(
11731122 log .debug ("Calculate pairwise shifts options: <%s>" , options )
11741123 IJ .run ("Calculate pairwise shifts ..." , str (options ))
11751124
1176- backup_xml_files (
1177- file_info ["path" ], "phase_correlation_shift_calculation"
1178- )
1125+ backup_xml_files (file_info ["path" ], "phase_correlation_shift_calculation" )
11791126
11801127
11811128def filter_pairwise_shifts (
@@ -1287,9 +1234,7 @@ def optimize_and_apply_shifts(
12871234 + processing_opts .fmt_how_to_treat ()
12881235 )
12891236
1290- log .debug (
1291- "Optimization and shifts application options: <%s>" , options
1292- )
1237+ log .debug ("Optimization and shifts application options: <%s>" , options )
12931238 IJ .run ("Optimize globally and apply shifts ..." , str (options ))
12941239
12951240 backup_xml_files (file_info ["path" ], "optimize_and_apply_shifts" )
@@ -1469,26 +1414,18 @@ def duplicate_transformations(
14691414 target = "[All Channels]"
14701415 source = str (channel_source - 1 )
14711416 if tile_source :
1472- tile_apply = (
1473- "apply_to_tile=[Single tile (Select from List)] "
1474- )
1475- tile_process = (
1476- "processing_tile=[tile " + str (tile_source ) + "] "
1477- )
1417+ tile_apply = "apply_to_tile=[Single tile (Select from List)] "
1418+ tile_process = "processing_tile=[tile " + str (tile_source ) + "] "
14781419 else :
14791420 tile_apply = "apply_to_tile=[All tiles] "
14801421 elif transformation_type == "tile" :
14811422 apply = "[One tile to other tiles]"
14821423 target = "[All Tiles]"
14831424 source = str (tile_source )
14841425 if channel_source :
1485- chnl_apply = (
1486- "apply_to_channel=[Single channel (Select from List)] "
1487- )
1426+ chnl_apply = "apply_to_channel=[Single channel (Select from List)] "
14881427 chnl_process = (
1489- "processing_channel=[channel "
1490- + str (channel_source - 1 )
1491- + "] "
1428+ "processing_channel=[channel " + str (channel_source - 1 ) + "] "
14921429 )
14931430 else :
14941431 chnl_apply = "apply_to_channel=[All channels] "
0 commit comments