py4dstem / py4dstem/py4DSTEM

Broken read_mib.py module in version 0.14.18

Open
#707 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
279
Forks
177
PR merge metrics
No merged PRs in 30d

Description

Hi!
Looks like the read_mib.py module is broken in version 0.14.18.

-> Version 0.14.17:

datacube = py4DSTEM.import_file("data_scan64x64.mib", scan=(64,64))

Loads data without errors.

-> Version 0.14.18:

datacube = py4DSTEM.import_file("data_scan64x64.mib", scan=(64,64))

Error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[3], [line 1](vscode-notebook-cell:?execution_count=3&line=1)
----> [1](vscode-notebook-cell:?execution_count=3&line=1) datacube = py4DSTEM.import_file("data_scan64x64.mib", scan=(64,64))

File c:\Users\AL282703\AppData\Local\miniforge3\envs\nt4dstem\Lib\site-packages\py4DSTEM\io\importfile.py:90, in import_file(filepath, mem, binfactor, filetype, **kwargs)
     [87](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/importfile.py:87) # elif filetype == "kitware_counted":
     [88](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/importfile.py:88) #    data = read_kitware_counted(filepath, mem, binfactor, metadata=metadata, **kwargs)
     [89](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/importfile.py:89) elif filetype == "mib":
---> [90](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/importfile.py:90)     data = load_mib(filepath, mem=mem, binfactor=binfactor, **kwargs)
     [91](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/importfile.py:91) elif filetype == "arina":
     [92](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/importfile.py:92)     from py4DSTEM.io.filereaders import read_arina

File c:\Users\AL282703\AppData\Local\miniforge3\envs\nt4dstem\Lib\site-packages\py4DSTEM\io\filereaders\read_mib.py:81, in load_mib(file_path, mem, binfactor, reshape, scan)
     [78](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/filereaders/read_mib.py:78)     print("Data type not supported as MIB reader")
     [80](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/filereaders/read_mib.py:80) if reshape:
---> [81](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/filereaders/read_mib.py:81)     data = data.reshape(scan[0], scan[1], width, height)
     [82](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/filereaders/read_mib.py:82) else:
     [83](file:///C:/Users/AL282703/AppData/Local/miniforge3/envs/nt4dstem/Lib/site-packages/py4DSTEM/io/filereaders/read_mib.py:83)     data = data[:, None, :, :]

TypeError: 'NoneType' object is not subscriptable

I can work with version 0.14.17 right now, but that might be a problem in the future. Maybe this is fixed in version 0.14.19? Could you take a look?

Thanks!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with py4DSTEM.import_file("data_scan64x64.mib", scan=(64,64)) and compare versions 0.14.17 and 0.14.18. Start in py4DSTEM/io/filereaders/read_mib.py at load_mib, reached through py4DSTEM/io/importfile.py, and trace the reshape path. Done means the MIB file loads with the scan argument without the NoneType error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.