From 7d5ab57e2c0ba3e5e790066e5de1ff60988168d0 Mon Sep 17 00:00:00 2001 From: Johanna Rahm <48733135+JohannaRahm@users.noreply.github.com> Date: Fri, 17 Jun 2022 01:14:18 -0700 Subject: [PATCH] Inference bug, pandas docker version (#153) * fix channel_name bug * set pandas to 0.24.2 in docker requirements * add test & update docstring for aux_utils - get_sms_im_name function Co-authored-by: Jenny Folkesson <6796901+jennyfolkesson@users.noreply.github.com> --- micro_dl/utils/aux_utils.py | 6 +++--- requirements_docker.txt | 2 +- tests/utils/aux_utils_tests.py | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/micro_dl/utils/aux_utils.py b/micro_dl/utils/aux_utils.py index 9882ed42..90317645 100644 --- a/micro_dl/utils/aux_utils.py +++ b/micro_dl/utils/aux_utils.py @@ -184,7 +184,7 @@ def get_sms_im_name(time_idx=None, This function is custom for the computational microscopy (SMS) group, who has the following file naming convention: File naming convention is assumed to be: - img_channelname_t***_p***_z***.tif + img_channelname_t***_p***_z***_extrafield.tif This function will alter list and dict in place. :param int time_idx: Time index @@ -194,11 +194,11 @@ def get_sms_im_name(time_idx=None, :param str extra_field: Any extra string you want to include in the name :param str ext: Extension, e.g. '.png' :param int int2str_len: Length of string of the converted integers - :return st im_name: Image file name + :return str im_name: Image file name """ im_name = "img" - if np.isnan(channel_name): + if not pd.isnull(channel_name): im_name += "_" + str(channel_name) if time_idx is not None: im_name += "_t" + str(time_idx).zfill(int2str_len) diff --git a/requirements_docker.txt b/requirements_docker.txt index f3c4ca32..dc31c83d 100644 --- a/requirements_docker.txt +++ b/requirements_docker.txt @@ -4,7 +4,7 @@ natsort==6.0.0 nose==1.3.7 numpy==1.21.0 opencv-python==4.4.0.40 -pandas==1.1.5 +pandas==0.24.2 protobuf==3.20.1 pydot==1.4.1 PyYAML>=5.4 diff --git a/tests/utils/aux_utils_tests.py b/tests/utils/aux_utils_tests.py index 82f00527..db4cd60d 100644 --- a/tests/utils/aux_utils_tests.py +++ b/tests/utils/aux_utils_tests.py @@ -95,6 +95,32 @@ def test_get_im_name(): nose.tools.assert_equal(im_name, 'im_c2_z3_t1_p4_hej.png') +def test_get_sms_im_name(): + im_name = aux_utils.get_sms_im_name( + time_idx=0, + channel_name='phase', + slice_idx=10, + pos_idx=100, + extra_field='blub', + ext='.png', + int2str_len=3, + ) + nose.tools.assert_equal(im_name, 'img_phase_t000_p100_z010_blub.png') + + +def test_get_sms_im_name_nones(): + im_name = aux_utils.get_sms_im_name( + time_idx=0, + channel_name=None, + slice_idx=None, + pos_idx=10, + extra_field=None, + ext='.jpg', + int2str_len=2, + ) + nose.tools.assert_equal(im_name, 'img_t00_p10.jpg') + + def test_get_im_name_default(): im_name = aux_utils.get_im_name() nose.tools.assert_equal(im_name, 'im.png')