Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

options for OSError: MCD file corrupted #18

Open
matt-sd-watson opened this issue Jun 1, 2023 · 2 comments
Open

options for OSError: MCD file corrupted #18

matt-sd-watson opened this issue Jun 1, 2023 · 2 comments

Comments

@matt-sd-watson
Copy link

Our group has had several instances where .mcd files are parsed and experience the following types of mcd file corruption errors:

OSError: inconsistent acquisition image data size
OSError: mcd file corrupted: invalid acquisition image data offsets

Are there options in readimc for how to handle or generalize the errors for these types of mcds? In many cases the source of the error needs to be investigated by the individual who ran the experiment, and because the MCDFile parser seems to be quite restrictive with these error warnings, these data cannot be read into our programs when these errors arise.

@jwindhager
Copy link
Contributor

jwindhager commented Jun 1, 2023

Hi @matt-sd-watson,

These errors indicate that the MCD files are corrupted, meaning that the metadata in the MCD files that specifies which part of the MCD file contains the imaging data is inconsistent with the expected image size. In such situations you probably want to resort to the (redundant) acquisition TXT files to recover the data, instead of trying to recover the acquisition data from the MCD file:

try:
    img = mcd_file.read_acquisition(acquisition)
except IOError:
    img = acquisition_txt_file.read_acquisition()

Currently, readimc does not offer options to ignore the error message. If you would like to work on a more lenient version of read_acquisition (i.e., some heuristics for locating the data within the "metadata-broken" MCD file), you are more than welcome to submit a PR :-)

@KaWingLee9
Copy link

@matt-sd-watson An error caused by the conditional statement in read_accquisition. I successfully overcame it by removing the the following scripts:

    # if width * height != len(df.index):
    #     if strict:
    #         raise IOError(
    #             f"TXT file '{self.path.name}' corrupted: "
    #             "inconsistent acquisition image data size"
    #         )
    #     warn(
    #         f"TXT file '{self.path.name}' corrupted: "
    #         "inconsistent acquisition image data size"
    #     )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants