Skip to content

Fix legacy hdf5 loading #424

@ljchang

Description

@ljchang

@ejolly, just tried using the new hdf5 loading for an older file and encoutered this error message:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[33], line 16
     12 f = file_list[0]
     14 sub = os.path.basename(f).split('_')[0]
---> 16 fmri_data = Brain_Data(f)

File ~/Github/nltools/nltools/data/brain_data.py:206, in Brain_Data.__init__(self, data, Y, X, mask, **kwargs)
    203 else:
    204     # Load X and Y dataframes
    205     with pd.HDFStore(to_load, "r") as f:
--> 206         self.X = f["X"]
    207         self.Y = f["Y"]
    209     # Load data and masker stuffs

File ~/opt/anaconda3/lib/python3.11/site-packages/pandas/io/pytables.py:602, in HDFStore.__getitem__(self, key)
    601 def __getitem__(self, key: str):
--> 602     return self.get(key)

File ~/opt/anaconda3/lib/python3.11/site-packages/pandas/io/pytables.py:813, in HDFStore.get(self, key)
    811 if group is None:
    812     raise KeyError(f"No object named {key} in the file")
--> 813 return self._read_group(group)

File ~/opt/anaconda3/lib/python3.11/site-packages/pandas/io/pytables.py:1878, in HDFStore._read_group(self, group)
   1877 def _read_group(self, group: Node):
-> 1878     s = self._create_storer(group)
   1879     s.infer_axes()
   1880     return s.read()

File ~/opt/anaconda3/lib/python3.11/site-packages/pandas/io/pytables.py:1752, in HDFStore._create_storer(self, group, format, value, encoding, errors)
   1750         tt = "generic_table"
   1751     else:
-> 1752         raise TypeError(
   1753             "cannot create a storer if the object is not existing "
   1754             "nor a value are passed"
   1755         )
   1756 else:
   1757     if isinstance(value, Series):

TypeError: cannot create a storer if the object is not existing nor a value are passed

I don't believe there should be any metadata stored in these files. Is this something is simple as just checking and initializing with an empty value?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions