Skip to content

Commit b170ff9

Browse files
authored
Merge pull request #55 from /issues/47
BDV docstrings, fixing #47
2 parents 0862cb2 + b02198e commit b170ff9

1 file changed

Lines changed: 72 additions & 63 deletions

File tree

src/imcflibs/imagej/bdv.py

Lines changed: 72 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ def reference_angle(self, value):
113113
114114
Select the angle(s) to use for the operation, by default empty (`""`).
115115
116-
NOTE: this value will be used to render `angles=[use Angle VALUE]` when calling
117-
the `fmt_use_acitt()` method.
116+
NOTE: this value will be used to render `angles=[use Angle VALUE]` when
117+
calling the `fmt_use_acitt()` method.
118118
119119
Parameters
120120
----------
@@ -127,11 +127,11 @@ def reference_angle(self, value):
127127
def reference_channel(self, value):
128128
"""Set the reference channel when using *Expert Grouping Options*.
129129
130-
Select the channel(s) to use for the operation, by default the averaging mode
131-
will be used (`channels=[Average Channels]`).
130+
Select the channel(s) to use for the operation, by default the averaging
131+
mode will be used (`channels=[Average Channels]`).
132132
133-
NOTE: this value will be used to render `channels=[use Channel VALUE]` when
134-
calling the `fmt_use_acitt()` method.
133+
NOTE: this value will be used to render `channels=[use Channel VALUE]`
134+
when calling the `fmt_use_acitt()` method.
135135
136136
Parameters
137137
----------
@@ -147,11 +147,11 @@ def reference_channel(self, value):
147147
def reference_illumination(self, value):
148148
"""Set the reference illumination when using *Expert Grouping Options*.
149149
150-
Select the illumination(s) to use for the operation, by default the averaging
151-
mode will be used (`illuminations=[Average Illuminations]`).
150+
Select the illumination(s) to use for the operation, by default the
151+
averaging mode will be used (`illuminations=[Average Illuminations]`).
152152
153-
NOTE: this value will be used to render `illuminations=[use Illumination VALUE]`
154-
when calling the `fmt_use_acitt()` method.
153+
NOTE: this value will be used to render `illuminations=[use Illumination
154+
VALUE]` when calling the `fmt_use_acitt()` method.
155155
156156
Parameters
157157
----------
@@ -169,11 +169,11 @@ def reference_illumination(self, value):
169169
def reference_tile(self, value):
170170
"""Set the reference tile when using *Expert Grouping Options*.
171171
172-
Select the tile(s) to use for the operation, by default the averaging mode will
173-
be used (`tiles=[Average Tiles]`).
172+
Select the tile(s) to use for the operation, by default the averaging
173+
mode will be used (`tiles=[Average Tiles]`).
174174
175-
NOTE: this value will be used to render `tiles=[use Tile VALUE]` when calling
176-
the `fmt_use_acitt()` method.
175+
NOTE: this value will be used to render `tiles=[use Tile VALUE]` when
176+
calling the `fmt_use_acitt()` method.
177177
178178
Parameters
179179
----------
@@ -186,11 +186,11 @@ def reference_tile(self, value):
186186
def reference_timepoint(self, value):
187187
"""Set the reference timepoint when using *Expert Grouping Options*.
188188
189-
Select the timepoint(s) to use for the operation, by default the averaging mode
190-
will be used (`timepoints=[Average Timepoints]`).
189+
Select the timepoint(s) to use for the operation, by default the
190+
averaging mode will be used (`timepoints=[Average Timepoints]`).
191191
192-
NOTE: this value will be used to render `timepoints=[use Timepoint VALUE]` when
193-
calling the `fmt_use_acitt()` method.
192+
NOTE: this value will be used to render `timepoints=[use Timepoint
193+
VALUE]` when calling the `fmt_use_acitt()` method.
194194
195195
Parameters
196196
----------
@@ -239,7 +239,7 @@ def process_channel(self, value, range_end=None):
239239
Parameters
240240
----------
241241
value : str, int, list of int or list of str
242-
The channel(s) to use for processing, either a single value or a list.
242+
The channel(s) to use for processing, a single value or a list.
243243
range_end : int, optional
244244
Contains the end of the range, by default None.
245245
@@ -259,13 +259,13 @@ def process_channel(self, value, range_end=None):
259259
def process_illumination(self, value, range_end=None):
260260
"""Set the processing option for illuminations.
261261
262-
Update the illumination processing option and selection depending on input.
263-
If the range_end is not None, it is considered as a range.
262+
Update the illumination processing option and selection depending on
263+
input. If the range_end is not None, it is considered as a range.
264264
265265
Parameters
266266
----------
267267
value : str, int, list of int or list of str
268-
The illumination(s) to use for processing, either a single value or a list.
268+
The illumination(s) to use for processing, a single value or a list.
269269
range_end : int, optional
270270
Contains the end of the range, by default None.
271271
@@ -291,7 +291,7 @@ def process_tile(self, value, range_end=None):
291291
Parameters
292292
----------
293293
value : str, int, list of int or list of str
294-
The tile(s) to use for processing, either a single value or a list.
294+
The tile(s) to use for processing, a single value or a list.
295295
range_end : int, optional
296296
Contains the end of the range, by default None.
297297
@@ -317,7 +317,7 @@ def process_timepoint(self, value, range_end=None):
317317
Parameters
318318
----------
319319
value : str, int, list of int or list of str
320-
The timepoint(s) to use for processing, either a single value or a list.
320+
The timepoint(s) to use for processing, a single value or a list.
321321
range_end : int, optional
322322
Contains the end of the range, by default None.
323323
@@ -683,8 +683,9 @@ def fmt_acitt_options(self):
683683
"""Format Angle / Channel / Illumination / Tile / Timepoint options.
684684
685685
Build a string providing the `multiple_angles`, `multiple_channels`,
686-
`multiple_illuminations_directions`, `multiple_tiles` and `multiple_timepoints` options
687-
that can be used in a BDV-related `IJ.run` call.
686+
`multiple_illuminations_directions`, `multiple_tiles` and
687+
`multiple_timepoints` options that can be used in a BDV-related `IJ.run`
688+
call.
688689
689690
Returns
690691
-------
@@ -708,14 +709,15 @@ def fmt_acitt_options(self):
708709
def check_processing_input(value, range_end):
709710
"""Sanitize and clarifies the acitt input selection.
710711
711-
Check if the input is valid by checking the type and returning the expected output.
712+
Validate the input by checking the type and returning the expected output.
712713
713714
Parameters
714715
----------
715716
value : str, int, list of int or list of str
716-
Contains the list of input dimensions, the first input dimension of a range or a single channel
717+
Contains the list of input dimensions, the first input dimension of a
718+
range or a single channel.
717719
range_end : int or None
718-
Contains the end of the range if need be
720+
Contains the end of the range if need be.
719721
720722
Returns
721723
-------
@@ -731,13 +733,9 @@ def check_processing_input(value, range_end):
731733
)
732734
if type(range_end) is int:
733735
if type(value[0]) is not int:
734-
raise TypeError(
735-
"Invalid input type. Expected an int for the range start"
736-
)
736+
raise TypeError("Range start needs to be an int.")
737737
elif len(value) != 1:
738-
raise ValueError(
739-
"Invalid input type. Expected a single number for the range start"
740-
)
738+
raise ValueError("Range start needs to be single number.")
741739
else:
742740
return "range"
743741
elif len(value) == 1:
@@ -747,26 +745,31 @@ def check_processing_input(value, range_end):
747745

748746

749747
def get_processing_settings(dimension, selection, value, range_end):
750-
"""Get the variables corresponding to the dimension selection and processing mode.
748+
"""Generate processing strings for selected dimension and processing mode.
751749
752-
Get the processing option and dimension selection string that corresponds
753-
to the selected processing mode.
750+
Generate the processing option and dimension selection strings that
751+
correspond to the selected processing mode and the given dimension
752+
selection.
754753
755754
Parameters
756755
----------
757-
dimension : str
758-
"angle", "channel", "illumination", "tile" or "timepoint"
759-
selection : str
760-
"single", "multiple", or "range"
756+
dimension : {`angle`, `channel`, `illumination`, `tile`, `timepoint`}
757+
The dimension selection to use.
758+
selection : {`single`, `multiple`, `range`}
759+
The *selector* name ("processing mode"), used to derive how the
760+
generated string needs to be assembled according to the given dimension
761+
and value / range settings.
761762
value : str, int, list of int or list of str
762-
Contains the list of input dimensions, the first input dimension of a range or a single channel
763+
The list of input dimensions, the first input dimension of a range or a
764+
single dimension value in case `selection == "single"` (e.g. for
765+
selecting a single channel).
763766
range_end : int or None
764-
Contains the end of the range if need be
767+
Contains the end of the range if need be.
765768
766769
Returns
767770
-------
768-
list of str
769-
processing options string, dimension selection string
771+
tuple of str
772+
processing_option, dimension_select
770773
"""
771774

772775
if selection == "single":
@@ -804,9 +807,9 @@ def get_processing_settings(dimension, selection, value, range_end):
804807
def backup_xml_files(source_directory, subfolder_name):
805808
"""Create a backup of BDV-XML files inside a subfolder of `xml-backup`.
806809
807-
Copies all `.xml` and `.xml~` files to a subfolder with the given name inside a
808-
folder called `xml-backup` in the source directory. Uses the `shutil.copy2()`
809-
command, which will overwrite existing files.
810+
Copies all `.xml` and `.xml~` files to a subfolder with the given name
811+
inside a folder called `xml-backup` in the source directory. Uses the
812+
`shutil.copy2()` command, which will overwrite existing files.
810813
811814
Parameters
812815
----------
@@ -852,8 +855,8 @@ def define_dataset_auto(
852855
with an extension.
853856
dataset_save_path : str
854857
Output path for the `.xml`.
855-
bf_series_type : str
856-
One of "Angles" or "Tiles", specifying how Bio-Formats interprets the series.
858+
bf_series_type : {`Angles`,`Tiles`}
859+
Defines how Bio-Formats interprets the series.
857860
timepoints_per_partition : int, optional
858861
Split the output dataset by timepoints. Use `0` for no split, resulting
859862
in a single HDF5 file containing all timepoints. By default `1`,
@@ -912,7 +915,8 @@ def define_dataset_auto(
912915
+ "bioformats_series_are?="
913916
+ bf_series_type
914917
+ " "
915-
+ "move_tiles_to_grid_(per_angle)?=[Do not move Tiles to Grid (use Metadata if available)] "
918+
+ "move_tiles_to_grid_(per_angle)?=["
919+
+ "Do not move Tiles to Grid (use Metadata if available)] "
916920
+ "how_to_store_input_images=["
917921
+ resave
918922
+ "] "
@@ -957,8 +961,8 @@ def define_dataset_manual(
957961
source_directory : str
958962
Path to the folder containing the file(s).
959963
image_file_pattern : str
960-
Regular expression corresponding to the names of your files and how to read the
961-
different dimensions.
964+
Regular expression corresponding to the names of your files and how to
965+
read the different dimensions.
962966
dataset_organisation : str
963967
Organisation of the dataset and the dimensions to process.
964968
Allows for defining the range of interest of the different dimensions.
@@ -1391,8 +1395,10 @@ def interest_points_registration(
13911395
+ processing_opts.fmt_acitt_options()
13921396
+ processing_opts.fmt_acitt_selectors()
13931397
+ "registration_algorithm=[Precise descriptor-based (translation invariant)] "
1394-
+ "registration_over_time=[Match against one reference timepoint (no global optimization)] "
1395-
+ "registration_in_between_views=[Only compare overlapping views (according to current transformations)] "
1398+
+ "registration_over_time=["
1399+
+ "Match against one reference timepoint (no global optimization)] "
1400+
+ "registration_in_between_views=["
1401+
+ "Only compare overlapping views (according to current transformations)] "
13961402
+ "interest_point_inclusion=[Compare all interest point of overlapping views] "
13971403
+ "interest_points=beads "
13981404
+ "group_tiles "
@@ -1409,8 +1415,11 @@ def interest_points_registration(
14091415
+ "significance=3 "
14101416
+ "allowed_error_for_ransac=5 "
14111417
+ "ransac_iterations=Normal "
1412-
+ "global_optimization_strategy=[Two-Round: Handle unconnected tiles, remove wrong links RELAXED (5.0x / 7.0px)] "
1413-
+ "interestpoint_grouping=[Group interest points (simply combine all in one virtual view)] "
1418+
+ "global_optimization_strategy=["
1419+
+ "Two-Round: Handle unconnected tiles, "
1420+
+ "remove wrong links RELAXED (5.0x / 7.0px)] "
1421+
+ "interestpoint_grouping=["
1422+
+ "Group interest points (simply combine all in one virtual view)] "
14141423
+ "interest=5"
14151424
)
14161425

@@ -1656,7 +1665,7 @@ def fuse_dataset_bdvp(
16561665
):
16571666
"""Export a BigDataViewer project using the BIOP Kheops exporter.
16581667
1659-
This function uses the BIOP Kheops exporter to convert a BigDataViewer project into a
1668+
Use the BIOP Kheops exporter to convert a BigDataViewer project into
16601669
OME-TIFF files, with optional compression.
16611670
16621671
Parameters
@@ -1666,11 +1675,11 @@ def fuse_dataset_bdvp(
16661675
command : CommandService
16671676
The Scijava CommandService instance to execute the export command.
16681677
processing_opts : ProcessingOptions, optional
1669-
Options defining which parts of the dataset to process. If None, default processing
1670-
options will be used (process all angles, channels, etc.).
1678+
Options defining which parts of the dataset to process. If None, default
1679+
processing options will be used (process all angles, channels, etc.).
16711680
result_path : str, optional
1672-
Path where to store the exported files. If None, files will be saved in the same
1673-
directory as the input project.
1681+
Path where to store the exported files. If None, files will be saved in
1682+
the same directory as the input project.
16741683
compression : str, optional
16751684
Compression method to use for the TIFF files. Default is "LZW".
16761685

0 commit comments

Comments
 (0)