Forráskód Böngészése

gin commit from Ivory

New files: 2
Modified files: 3
Achilleas Koutsou 5 éve
szülő
commit
e8a090166f
5 módosított fájl, 299 hozzáadás és 12 törlés
  1. 1 1
      EEG for MNE/LED_28_06_2012_104.nix
  2. 35 0
      infos
  3. 5 3
      mnetonix.py
  4. 39 8
      readrawnix.py
  5. 219 0
      types

+ 1 - 1
EEG for MNE/LED_28_06_2012_104.nix

@@ -1 +1 @@
-/annex/objects/MD5-s39581154--ca6f33ef9bc9831c91d072a082d35497
+/annex/objects/MD5-s39611069--2886b8c107c709e8120838b851174e2d

+ 35 - 0
infos

@@ -0,0 +1,35 @@
+<Info | 16 non-empty fields
+    bads : list | 0 items
+    ch_names : list | Fp1, Fp2, F3, F4, C3, C4, P3, P4, O1, ...
+    chs : list | 19 items (EEG: 19)
+    comps : list | 0 items
+    custom_ref_applied : bool | False
+    dev_head_t : dict | 3 items
+    events : list | 0 items
+    highpass : float | 0.015915494309189534 Hz
+    hpi_meas : list | 0 items
+    hpi_results : list | 0 items
+    lowpass : float | 250.0 Hz
+    meas_date : tuple | 2012-06-28 14:54:38 GMT
+    nchan : int | 19
+    proc_history : list | 0 items
+    projs : list | 0 items
+    sfreq : float | 1000.0 Hz
+    acq_pars : NoneType
+    acq_stim : NoneType
+    ctf_head_t : NoneType
+    description : NoneType
+    dev_ctf_t : NoneType
+    dig : NoneType
+    experimenter : NoneType
+    file_id : NoneType
+    gantry_angle : NoneType
+    hpi_subsystem : NoneType
+    kit_system_id : NoneType
+    line_freq : NoneType
+    meas_id : NoneType
+    proj_id : NoneType
+    proj_name : NoneType
+    subject_info : NoneType
+    xplotter_layout : NoneType
+>

+ 5 - 3
mnetonix.py

@@ -79,7 +79,8 @@ def create_md_tree(section, values, block):
                                              data=v)
                 for _ in range(ndim):
                     da.append_set_dimension()
-                section.create_property(k, da.id)
+                prop = section.create_property(k, da.id)
+                prop.type = str(v.__class__)
                 da.metadata = section
                 continue
             # check element type
@@ -100,10 +101,11 @@ def create_md_tree(section, values, block):
                 continue
 
         try:
-            section.create_property(k, v)
+            prop = section.create_property(k, v)
         except TypeError:
             # inconsistent iterable types: upgrade to floats
-            section.create_property(k, [float(vi) for vi in v])
+            prop = section.create_property(k, [float(vi) for vi in v])
+        prop.type = str(v.__class__)
 
 
 def write_single_da(mneraw, block):

+ 39 - 8
readrawnix.py

@@ -1,22 +1,52 @@
 import os
 import sys
+import numpy as np
 import nixio as nix
 import mne
 
 
+typemap = {
+    "str": str,
+    "int": int,
+    "float": float,
+    "bool": bool,
+    "tuple": tuple,
+    "list": list,
+    "numpy.float64": np.float64,
+    "numpy.ndarray": np.array,
+}
+
+
+def convert_prop_type(prop):
+    pt = prop.type[8:-2]
+    pv = prop.values
+    if len(pv) == 1:
+        pv = pv[0]
+
+    return typemap[pt](pv)
+
+
 def md_to_dict(section):
     sdict = dict()
     for prop in section.props:
-        values = list(prop.values)
-        if len(values) == 1:
-            values = values[0]
-        sdict[prop.name] = values
+        sdict[prop.name] = convert_prop_type(prop)
+
+    if section.type[8:-2] == "mne.transforms.Transform":
+        to = sdict["to"]
+        fro = sdict["from"]
+        trans = sdict["trans"]
+        trans = section.referring_data_arrays()[0][:]
+        return mne.Transform(to, fro, trans)
 
     for sec in section.sections:
         if sec.name == "chs":
-            print(str(sec) + "\n\n")
-            print("\n".join(str(s) for s in sec.sections))
-        sdict[sec.name] = md_to_dict(sec)
+            # make a list of dictionaries for the channels
+            chlist = list()
+            for chsec in sec.sections:
+                chlist.append(md_to_dict(chsec))
+                sdict[sec.name] = chlist
+        else:
+            sdict[sec.name] = md_to_dict(sec)
 
     return sdict
 
@@ -40,7 +70,8 @@ def main():
     info = mne.create_info(nchan, sfreq)
     print(info)
 
-    info.update(md_to_dict(infosec))
+    nixinfodict = md_to_dict(infosec)
+    info.update(nixinfodict)
 
     print(info)
     print(bvfile.info)

+ 219 - 0
types

@@ -0,0 +1,219 @@
+float
+float
+tuple
+bool
+float
+list
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+str
+int
+int
+int
+int
+numpy.float64
+numpy.float64
+numpy.ndarray
+int
+float
+int
+int
+int
+numpy.ndarray