Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions src/imcflibs/imagej/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def calculate_mean_and_stdv(values_list, round_decimals=0):

mean = round(sum(filtered_list) / len(filtered_list), round_decimals)
variance = sum((x - mean) ** 2 for x in filtered_list) / len(filtered_list)
std_dev = round(variance ** 0.5, round_decimals)
std_dev = round(variance**0.5, round_decimals)

return mean, std_dev

Expand Down Expand Up @@ -627,31 +627,6 @@ def save_image_in_format(imp, format, out_dir, series, pad_number, split_channel
current_imp.close()


def pad_number(index, pad_length=2):
"""Pad a number with leading zeros to a specified length.

Parameters
----------
index : int or str
The number to be padded
pad_length : int, optional
The total length of the resulting string after padding, by default 2

Returns
-------
str
The padded number as a string

Examples
--------
>>> pad_number(7)
'07'
>>> pad_number(42, 4)
'0042'
"""
return str(index).zfill(pad_length)


def locate_latest_imaris(paths_to_check=None):
"""Find paths to latest installed Imaris or ImarisFileConverter version.

Expand Down
25 changes: 25 additions & 0 deletions src/imcflibs/strtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,28 @@ def alphanum_key(key):
return [convert(c) for c in re.split("([0-9]+)", key)]

return sorted(data, key=alphanum_key)


def pad_number(index, pad_length=2):
"""Pad a number with leading zeros to a specified length.

Parameters
----------
index : int or str
The number to be padded
pad_length : int, optional
The total length of the resulting string after padding, by default 2

Returns
-------
str
The padded number as a string

Examples
--------
>>> pad_number(7)
'07'
>>> pad_number(42, 4)
'0042'
"""
return str(index).zfill(pad_length)
Loading