diff --git a/neuro_py/io/loading.py b/neuro_py/io/loading.py index a669fbb..64d2e3f 100644 --- a/neuro_py/io/loading.py +++ b/neuro_py/io/loading.py @@ -488,7 +488,7 @@ def un_nest_df(df): data = sio.loadmat(filename) # construct data frame with features per neuron - df = pd.DataFrame() + df = {} # count units n_cells = data["cell_metrics"]["UID"][0][0][0].size dt = data["cell_metrics"].dtype @@ -497,11 +497,17 @@ def un_nest_df(df): try: if (data["cell_metrics"][dn][0][0][0][0].size == 1) & ( data["cell_metrics"][dn][0][0][0].size == n_cells - ): - df[dn] = data["cell_metrics"][dn][0][0][0] + ): + # check if nested within brackets + try: + df[dn] = list(chain(*data["cell_metrics"][dn][0][0][0])) + except Exception: + df[dn] = data["cell_metrics"][dn][0][0][0] except Exception: continue + df = pd.DataFrame(df) + # load in tag # check if tags exist within cell_metrics if "tags" in data.get("cell_metrics").dtype.names: