Aharoni-Lab / miniscope-io

Data formatting, reading, and writing from miniscopes
https://miniscope-io.readthedocs.io
GNU Affero General Public License v3.0
6 stars 2 forks source link

bugfix: relative and absolute paths #9

Closed sneakers-the-rat closed 12 months ago

sneakers-the-rat commented 12 months ago

Previously, sdcard would try and resolve every path given to it. Now that behavior has been removed, allowing both relative and absolute paths.

reinstated throwing an exception when config can't be read, as that should stop any further use of the object since something has gone wrong with reading from it

Related to:

@t-sasatani I removed the try block around reading the config which was also added in https://github.com/Aharoni-Lab/miniscope-io/commit/bc9370a612ae69b9d182f08f8379762026004ba6 - i figured removing the resolve addresses the reason it was added? seems like throwing an I/O error there if the config can't be read is good to do, since the object shouldn't be used after that point if the file can't be read.

t-sasatani commented 12 months ago

I did a test run with an SD card. I'm unsure why and am still investigating, but a permission error occurs at the SDcard constructor, even when the SDcard can be accessed from the notebook.

  1. I can't locate something that could cause this in the code, but I'm assuming it's not a problem in my environment because of (2) and (3).
  2. The file can be opened repeatedly outside of the constructor. This is an example notebook that shows this (https://github.com/Aharoni-Lab/miniscope-io/blob/bigfix-permissionerror-example/notebooks/grab_frames.ipynb)
  3. This has yet to happen for v0.1.3, though I've tried both of them multiple times.
t-sasatani commented 12 months ago

seems like throwing an I/O error there if the config can't be read is good to do, since the object shouldn't be used after that point if the file can't be read.

Forgot to answer this. I just put it there because io errors happen a lot here (selecting the wrong drive number, admin privileges, driver issues, etc..) and should have added an exit code.

t-sasatani commented 12 months ago

I'm sure there are better solutions than this, but changing,

        self.drive = Path(drive)

to

        self.drive = drive

makes it work both for the external drive and the image file (https://github.com/Aharoni-Lab/miniscope-io/pull/9/commits/6b929b1e1c0111c89eade2a0e55daca01c9cc7e1). I assume it's because the SD card's path can not be resolved properly because it doesn't have a file system and this could be a tentative solution.