File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -1657,9 +1657,13 @@ def rgb2gray(rgb):
1657
1657
return movie (** f ).astype (outtype )
1658
1658
1659
1659
elif extension in ('.hdf5' , '.h5' , '.nwb' ):
1660
+ # TODO: Merge logic here with utilities.py:get_file_size()
1660
1661
with h5py .File (file_name , "r" ) as f :
1661
- fkeys = list (f .keys ())
1662
- if len (fkeys ) == 1 : # If the hdf5 file we're parsing has only one dataset inside it, ignore the arg and pick that dataset
1662
+ ignore_keys = ['__DATA_TYPES__' ] # Known metadata that tools provide, add to this as needed. Sync with utils.py:get_file_size() !!
1663
+ fkeys = list (filter (lambda x : x not in ignore_keys , f .keys ()))
1664
+ if len (fkeys ) == 1 and 'Dataset' in str (type (f [fkeys [0 ]])): # If the hdf5 file we're parsing has only one dataset inside it,
1665
+ # ignore the arg and pick that dataset
1666
+ # TODO: Consider recursing into a group to find a dataset
1663
1667
var_name_hdf5 = fkeys [0 ]
1664
1668
1665
1669
if extension == '.nwb' : # Apparently nwb files are specially-formatted hdf5 files
Original file line number Diff line number Diff line change @@ -1014,8 +1014,9 @@ def get_file_size(file_name, var_name_hdf5='mov'):
1014
1014
# FIXME this doesn't match the logic in movies.py:load()
1015
1015
# Consider pulling a lot of the "data source" code out into one place
1016
1016
with h5py .File (file_name , "r" ) as f :
1017
- kk = list (f .keys ())
1018
- if len (kk ) == 1 :
1017
+ ignore_keys = ['__DATA_TYPES__' ] # Known metadata that tools provide, add to this as needed. Sync with movies.my:load() !!
1018
+ kk = list (filter (lambda x : x not in ignore_keys , f .keys ()))
1019
+ if len (kk ) == 1 and 'Dataset' in str (type (f [kk [0 ]])): # TODO: Consider recursing into a group to find a dataset
1019
1020
siz = f [kk [0 ]].shape
1020
1021
elif var_name_hdf5 in f :
1021
1022
if extension == '.nwb' :
You can’t perform that action at this time.
0 commit comments