Skip to content

Commit 0d5581d

Browse files
committed
Formatting
1 parent 2e9ad4a commit 0d5581d

File tree

1 file changed

+123
-41
lines changed

1 file changed

+123
-41
lines changed

src/imcflibs/imagej/bdv.py

Lines changed: 123 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ def reference_channel(self, value):
133133
"""
134134
# channel = int(value) - 1 # will raise a ValueError if cast fails
135135
self._use_channel = "channels=[use Channel %s]" % int(value)
136-
log.debug("New reference channel setting: %s", self._use_channel)
136+
log.debug(
137+
"New reference channel setting: %s", self._use_channel
138+
)
137139

138140
def reference_illumination(self, value):
139141
"""Set the reference illumination when using *Expert Grouping Options*.
@@ -149,8 +151,13 @@ def reference_illumination(self, value):
149151
value : int or int-like
150152
The illumination number to use for the grouping.
151153
"""
152-
self._use_illumination = "illuminations=[use Illumination %s]" % value
153-
log.debug("New reference illumination setting: %s", self._use_illumination)
154+
self._use_illumination = (
155+
"illuminations=[use Illumination %s]" % value
156+
)
157+
log.debug(
158+
"New reference illumination setting: %s",
159+
self._use_illumination,
160+
)
154161

155162
def reference_tile(self, value):
156163
"""Set the reference tile when using *Expert Grouping Options*.
@@ -184,7 +191,9 @@ def reference_timepoint(self, value):
184191
The timepoint number to use for the grouping.
185192
"""
186193
self._use_timepoint = "timepoints=[use Timepoint %s]" % value
187-
log.debug("New reference timepoint setting: %s", self._use_timepoint)
194+
log.debug(
195+
"New reference timepoint setting: %s", self._use_timepoint
196+
)
188197

189198
### process-X methods
190199

@@ -406,16 +415,22 @@ def fmt_acitt_options(self, input="process"):
406415
"""
407416
input_type = ["process", "resave"]
408417
if input not in input_type:
409-
raise ValueError("Invalue input type. Expected one of: %s" % input_type)
418+
raise ValueError(
419+
"Invalue input type. Expected one of: %s" % input_type
420+
)
410421
parameters = [
411422
input + "_angle=" + self._angle_processing_option,
412423
input + "_channel=" + self._channel_processing_option,
413-
input + "_illumination=" + self._illumination_processing_option,
424+
input
425+
+ "_illumination="
426+
+ self._illumination_processing_option,
414427
input + "_tile=" + self._tile_processing_option,
415428
input + "_timepoint=" + self._timepoint_processing_option,
416429
]
417430
parameter_string = " ".join(parameters).strip()
418-
log.debug("Formatted 'process_X' options: <%s>", parameter_string)
431+
log.debug(
432+
"Formatted 'process_X' options: <%s>", parameter_string
433+
)
419434
return parameter_string + " "
420435

421436
def fmt_acitt_selectors(self):
@@ -435,12 +450,16 @@ def fmt_acitt_selectors(self):
435450
parameters = [
436451
self._angle_select if self._angle_select else "",
437452
self._channel_select if self._channel_select else "",
438-
self._illumination_select if self._illumination_select else "",
453+
self._illumination_select
454+
if self._illumination_select
455+
else "",
439456
self._tile_select if self._tile_select else "",
440457
self._timepoint_select if self._timepoint_select else "",
441458
]
442459
parameter_string = " ".join(parameters).strip()
443-
log.debug("Formatted 'processing_X' selectors: <%s>", parameter_string)
460+
log.debug(
461+
"Formatted 'processing_X' selectors: <%s>", parameter_string
462+
)
444463
return parameter_string + " "
445464

446465
def fmt_how_to_treat(self):
@@ -458,7 +477,9 @@ def fmt_how_to_treat(self):
458477
"how_to_treat_timepoints=" + self._treat_timepoints,
459478
]
460479
parameter_string = " ".join(parameters).strip()
461-
log.debug("Formatted 'how_to_treat_X' options: <%s>", parameter_string)
480+
log.debug(
481+
"Formatted 'how_to_treat_X' options: <%s>", parameter_string
482+
)
462483
return parameter_string + " "
463484

464485
def fmt_use_acitt(self):
@@ -473,13 +494,22 @@ def fmt_use_acitt(self):
473494
"""
474495
parameters = [
475496
self._use_angle if self._treat_angles == "group" else "",
476-
self._use_channel if self._treat_channels == "group" else "",
477-
self._use_illumination if self._treat_illuminations == "group" else "",
497+
self._use_channel
498+
if self._treat_channels == "group"
499+
else "",
500+
self._use_illumination
501+
if self._treat_illuminations == "group"
502+
else "",
478503
self._use_tile if self._treat_tiles == "group" else "",
479-
self._use_timepoint if self._treat_timepoints == "group" else "",
504+
self._use_timepoint
505+
if self._treat_timepoints == "group"
506+
else "",
480507
]
481508
parameter_string = " ".join(parameters).strip()
482-
log.debug("Formatted expert grouping 'use' options: <%s>", parameter_string)
509+
log.debug(
510+
"Formatted expert grouping 'use' options: <%s>",
511+
parameter_string,
512+
)
483513
return parameter_string + " "
484514

485515

@@ -517,7 +547,9 @@ class DefinitionOptions(object):
517547
def __init__(self):
518548
self._angle_definition = SINGLE_FILE % "angle"
519549
self._channel_definition = MULTI_SINGLE_FILE % "channel"
520-
self._illumination_definition = SINGLE_FILE % "illumination direction"
550+
self._illumination_definition = (
551+
SINGLE_FILE % "illumination direction"
552+
)
521553
self._tile_definition = MULTI_MULTI_FILE % "tile"
522554
self._timepoint_definition = SINGLE_FILE % "time-point"
523555

@@ -538,7 +570,9 @@ def check_definition_option(self, value):
538570
"multi_single",
539571
"multi_multi",
540572
]:
541-
raise ValueError("Value must be one of single, multi_multi or multi_single")
573+
raise ValueError(
574+
"Value must be one of single, multi_multi or multi_single"
575+
)
542576

543577
return {
544578
"single": SINGLE_FILE,
@@ -584,7 +618,9 @@ def set_angle_definition(self, value):
584618
"""
585619
choices = self.check_definition_option_ang_ill(value)
586620
self._angle_definition = choices[value] % "angle"
587-
log.debug("New 'angle_definition' setting: %s", self._angle_definition)
621+
log.debug(
622+
"New 'angle_definition' setting: %s", self._angle_definition
623+
)
588624

589625
def set_channel_definition(self, value):
590626
"""Set the value for the channel definition
@@ -596,7 +632,10 @@ def set_channel_definition(self, value):
596632
"""
597633
choices = self.check_definition_option(value)
598634
self._channel_definition = choices[value] % "channel"
599-
log.debug("New 'channel_definition' setting: %s", self._channel_definition)
635+
log.debug(
636+
"New 'channel_definition' setting: %s",
637+
self._channel_definition,
638+
)
600639

601640
def set_illumination_definition(self, value):
602641
"""Set the value for the illumination definition
@@ -607,9 +646,12 @@ def set_illumination_definition(self, value):
607646
One of `single`, `multi_single` or `multi_multi`.
608647
"""
609648
choices = self.check_definition_option_ang_ill(value)
610-
self._illumination_definition = choices[value] % "illumination direction"
649+
self._illumination_definition = (
650+
choices[value] % "illumination direction"
651+
)
611652
log.debug(
612-
"New 'illumination_definition' setting: %s", self._illumination_definition
653+
"New 'illumination_definition' setting: %s",
654+
self._illumination_definition,
613655
)
614656

615657
def set_tile_definition(self, value):
@@ -622,7 +664,9 @@ def set_tile_definition(self, value):
622664
"""
623665
choices = self.check_definition_option(value)
624666
self._tile_definition = choices[value] % "tile"
625-
log.debug("New 'tile_definition' setting: %s", self._tile_definition)
667+
log.debug(
668+
"New 'tile_definition' setting: %s", self._tile_definition
669+
)
626670

627671
def set_timepoint_definition(self, value):
628672
"""Set the value for the time_point_definition
@@ -634,7 +678,10 @@ def set_timepoint_definition(self, value):
634678
"""
635679
choices = self.check_definition_option(value)
636680
self._timepoint_definition = choices[value] % "time-point"
637-
log.debug("New 'timepoint_definition' setting: %s", self._timepoint_definition)
681+
log.debug(
682+
"New 'timepoint_definition' setting: %s",
683+
self._timepoint_definition,
684+
)
638685

639686
def fmt_acitt_options(self):
640687
"""Format Angle / Channel / Illumination / Tile / Timepoint options.
@@ -650,12 +697,15 @@ def fmt_acitt_options(self):
650697
parameters = [
651698
"multiple_angles=" + self._angle_definition,
652699
"multiple_channels=" + self._channel_definition,
653-
"multiple_illuminations_directions=" + self._illumination_definition,
700+
"multiple_illuminations_directions="
701+
+ self._illumination_definition,
654702
"multiple_tiles=" + self._tile_definition,
655703
"multiple_timepoints=" + self._timepoint_definition,
656704
]
657705
parameter_string = " ".join(parameters).strip()
658-
log.debug("Formatted 'multiple_X' options: <%s>", parameter_string)
706+
log.debug(
707+
"Formatted 'multiple_X' options: <%s>", parameter_string
708+
)
659709
return parameter_string + " "
660710

661711

@@ -679,10 +729,14 @@ def check_processing_input(value, range_end):
679729
value = [value]
680730
# Check if all the elements of the value list are of the same type
681731
if not all(isinstance(x, type(value[0])) for x in value):
682-
raise TypeError("Invalid input type. All the values should be of the same type")
732+
raise TypeError(
733+
"Invalid input type. All the values should be of the same type"
734+
)
683735
if type(range_end) is int:
684736
if type(value[0]) is not int:
685-
raise TypeError("Invalid input type. Expected an int for the range start")
737+
raise TypeError(
738+
"Invalid input type. Expected an int for the range start"
739+
)
686740
elif len(value) != 1:
687741
raise ValueError(
688742
"Invalid input type. Expected a single number for the range start"
@@ -720,7 +774,13 @@ def get_processing_settings(dimension, selection, value, range_end):
720774

721775
if selection == "single":
722776
processing_option = SINGLE % dimension
723-
dimension_select = "processing_" + dimension + "=[" + dimension + " %s]" % value
777+
dimension_select = (
778+
"processing_"
779+
+ dimension
780+
+ "=["
781+
+ dimension
782+
+ " %s]" % value
783+
)
724784

725785
if selection == "multiple":
726786
processing_option = MULTIPLE % dimension
@@ -763,7 +823,9 @@ def backup_xml_files(source_directory, subfolder_name):
763823
pathtools.create_directory(xml_backup_directory)
764824
backup_subfolder = xml_backup_directory + "/%s" % (subfolder_name)
765825
pathtools.create_directory(backup_subfolder)
766-
all_xml_files = pathtools.listdir_matching(source_directory, ".*\\.xml", regex=True)
826+
all_xml_files = pathtools.listdir_matching(
827+
source_directory, ".*\\.xml", regex=True
828+
)
767829
os.chdir(source_directory)
768830
for xml_file in all_xml_files:
769831
shutil.copy2(xml_file, backup_subfolder)
@@ -823,7 +885,9 @@ def define_dataset_auto(
823885
dataset_save_path = result_folder
824886
if subsampling_factors:
825887
subsampling_factors = (
826-
"manual_mipmap_setup subsampling_factors=" + subsampling_factors + " "
888+
"manual_mipmap_setup subsampling_factors="
889+
+ subsampling_factors
890+
+ " "
827891
)
828892
else:
829893
subsampling_factors = ""
@@ -987,7 +1051,9 @@ def resave_as_h5(
9871051
split_hdf5 = ""
9881052

9891053
if subsampling_factors:
990-
subsampling_factors = "subsampling_factors=" + subsampling_factors + " "
1054+
subsampling_factors = (
1055+
"subsampling_factors=" + subsampling_factors + " "
1056+
)
9911057
else:
9921058
subsampling_factors = " "
9931059
if hdf5_chunk_sizes:
@@ -1077,10 +1143,13 @@ def phase_correlation_pairwise_shifts_calculation(
10771143
file_info = pathtools.parse_path(project_path)
10781144

10791145
if downsampling_xyz != "":
1080-
downsampling = "downsample_in_x=%s downsample_in_y=%s downsample_in_z=%s " % (
1081-
downsampling_xyz[0],
1082-
downsampling_xyz[1],
1083-
downsampling_xyz[2],
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+
)
10841153
)
10851154
else:
10861155
downsampling = ""
@@ -1104,7 +1173,9 @@ def phase_correlation_pairwise_shifts_calculation(
11041173
log.debug("Calculate pairwise shifts options: <%s>", options)
11051174
IJ.run("Calculate pairwise shifts ...", str(options))
11061175

1107-
backup_xml_files(file_info["path"], "phase_correlation_shift_calculation")
1176+
backup_xml_files(
1177+
file_info["path"], "phase_correlation_shift_calculation"
1178+
)
11081179

11091180

11101181
def filter_pairwise_shifts(
@@ -1216,7 +1287,9 @@ def optimize_and_apply_shifts(
12161287
+ processing_opts.fmt_how_to_treat()
12171288
)
12181289

1219-
log.debug("Optimization and shifts application options: <%s>", options)
1290+
log.debug(
1291+
"Optimization and shifts application options: <%s>", options
1292+
)
12201293
IJ.run("Optimize globally and apply shifts ...", str(options))
12211294

12221295
backup_xml_files(file_info["path"], "optimize_and_apply_shifts")
@@ -1394,18 +1467,26 @@ def duplicate_transformations(
13941467
target = "[All Channels]"
13951468
source = str(channel_source - 1)
13961469
if tile_source:
1397-
tile_apply = "apply_to_tile=[Single tile (Select from List)] "
1398-
tile_process = "processing_tile=[tile " + str(tile_source) + "] "
1470+
tile_apply = (
1471+
"apply_to_tile=[Single tile (Select from List)] "
1472+
)
1473+
tile_process = (
1474+
"processing_tile=[tile " + str(tile_source) + "] "
1475+
)
13991476
else:
14001477
tile_apply = "apply_to_tile=[All tiles] "
14011478
elif transformation_type == "tile":
14021479
apply = "[One tile to other tiles]"
14031480
target = "[All Tiles]"
14041481
source = str(tile_source)
14051482
if channel_source:
1406-
chnl_apply = "apply_to_channel=[Single channel (Select from List)] "
1483+
chnl_apply = (
1484+
"apply_to_channel=[Single channel (Select from List)] "
1485+
)
14071486
chnl_process = (
1408-
"processing_channel=[channel " + str(channel_source - 1) + "] "
1487+
"processing_channel=[channel "
1488+
+ str(channel_source - 1)
1489+
+ "] "
14091490
)
14101491
else:
14111492
chnl_apply = "apply_to_channel=[All channels] "
@@ -1441,7 +1522,8 @@ def duplicate_transformations(
14411522
IJ.run("Duplicate Transformations", str(options))
14421523

14431524
backup_xml_files(
1444-
file_info["path"], "duplicate_transformation_" + transformation_type
1525+
file_info["path"],
1526+
"duplicate_transformation_" + transformation_type,
14451527
)
14461528

14471529

0 commit comments

Comments
 (0)