Skip to content

[BUG] CSVOutput includes a no-name index row which trips PYMEVis loading #1688

Description

@barentine

Describe the bug
I think we want to be able to load a CSVOutput saved csv file in PYMEVis, but at the moment at least on my version of pandas, there is an extra row of each localization's index, and that row has no name.

<PYME.recipes.localisations.ProcessColour object at 0x12040c090>
ERROR:PYME.recipes.recipe:Error in recipe module: <PYME.recipes.localisations.ProcessColour object at 0x12040c090>
Traceback (most recent call last):
  File "/Users/andy/code/python-microscopy/PYME/recipes/recipe.py", line 238, in execute
    m.execute(self.namespace)
  File "/Users/andy/code/python-microscopy/PYME/recipes/base.py", line 336, in execute
    ret = self.run(**inputs)
          ^^^^^^^^^^^^^^^^^^
  File "/Users/andy/code/python-microscopy/PYME/recipes/localisations.py", line 430, in run
    cached_output = tabular.CachingResultsFilter(output)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andy/code/python-microscopy/PYME/IO/tabular.py", line 985, in __init__
    self.Index = np.ones(len(self.resultsSource), dtype=bool)
                         ^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andy/code/python-microscopy/PYME/IO/tabular.py", line 202, in __len__
    return len(self[list(self.keys())[0]])
               ~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/andy/code/python-microscopy/PYME/IO/tabular.py", line 1066, in __getitem__
    return self.resultsSource[keys]
           ~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/andy/code/python-microscopy/PYME/IO/tabular.py", line 1066, in __getitem__
    return self.resultsSource[keys]
           ~~~~~~~~~~~~~~~~~~^^^^^^
  File "/Users/andy/code/python-microscopy/PYME/IO/tabular.py", line 658, in __getitem__
    return self.res[key][sl]
           ~~~~~~~~^^^^^
ValueError: no field of name 

To Reproduce
Steps to reproduce the behavior:

  1. PYMEVis open some localizations
  2. Use the recipes tab to add a CSVOutput and save the locs to csv
  3. PYMEVis that csv file
  4. See error

Expected behavior
Open the CSV files we save

Platform (please complete the following information - or copy-paste from error dialog if shown):

  • pandas 3.0.2

Additional context

One fix is to save with the index=False flag:
v.to_csv(out_filename, index=False)
But maybe we would rather handle files with a no name index column on load?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions