chongxi / spiketag

Next generation of spike sorting package for BMI
BSD 3-Clause "New" or "Revised" License
6 stars 4 forks source link

probe class save and load issue #13

Closed chongxi closed 5 years ago

chongxi commented 5 years ago

prb.save('./bow_tie_LL.json') prb.load('./bow_tie_LL.json') prb.show()

it give an error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-7-33bbb65ebfc9> in <module>()
----> 1 prb.show()

/disk0/Work/pydev/spiketag/spiketag/base/Probe.py in show(self, font_size)
    281     def show(self, font_size=23):
    282         self.prb_view = probe_view()
--> 283         self.prb_view.set_data(self, font_size=font_size)
    284         self.prb_view.run()
    285 

/disk0/Work/pydev/spiketag/spiketag/view/probe_view.pyc in set_data(self, prb, font_size)
    109 
    110         if hasattr(prb, 'grp_dict'):
--> 111             self.edges, self.grp_idx = self.grp_2_edges(prb.grp_dict)
    112             # print edges
    113             self.edeges_color = np.ones((self.electrode_pos.shape[0], 4))*0.7

/disk0/Work/pydev/spiketag/spiketag/view/probe_view.pyc in grp_2_edges(self, grp_dict)
    128                 edges = np.array([i for i in comb(_grp, 2)])
    129             else:
--> 130                 edges = np.vstack((edges, np.array([i for i in comb(_grp, 2)])))
    131         # print edges
    132         return edges, _grp_idx

/disk0/anaconda2/lib/python2.7/site-packages/numpy/core/shape_base.pyc in vstack(tup)
    232 
    233     """
--> 234     return _nx.concatenate([atleast_2d(_m) for _m in tup], 0)
    235 
    236 def hstack(tup):

ValueError: all the input arrays must have same number of dimensions
chongxi commented 5 years ago

The problem is:

Before saving the json: prb:

0:[ 3  5 52 59]
1:[10 53 54 60]
2:[ 4 12 13 58]
3:[ 2 11 55 57]
4:[ 1  8 15 51]
5:[18 48 50 63]
6:[ 0 31 34 47]
7:[ 9 25 33 61]
8:[14 17 22 62]
9:[19 21 37 39]
10:[20 35 36 38]
11:[26 29 44 45]
12:[ 7 24 27 40]
13:[16 32 41 42]
14:[23 28 43 46]
15:[ 67  69 116 123]
16:[ 74 117 118 124]
17:[ 68  76  77 122]
18:[ 66  75 119 121]
19:[ 65  72  79 115]
20:[ 82 112 114 127]
21:[ 64  95  98 111]
22:[ 73  89  97 125]
23:[ 78  81  86 126]
24:[ 83  85 101 103]
25:[ 84  99 100 102]
26:[ 90  93 108 109]
27:[ 71  88  91 104]
28:[ 80  96 105 106]
29:[ 87  92 107 110]

aftet loading the json: prb:

0:[ 3  5 52 59]
1:[10 53 54 60]
2:[ 4 12 13 58]
3:[ 2 11 55 57]
4:[ 1  8 15 51]
5:[18 48 50 63]
6:[ 0 31 34 47]
7:[ 9 25 33 61]
8:[14 17 22 62]
9:[19 21 37 39]
10:[20 35 36 38]
11:[26 29 44 45]
12:[ 7 24 27 40]
13:[16 32 41 42]
14:[23 28 43 46]
15:[ 67  69 116 123]
16:[ 74 117 118 124]
17:[ 68  76  77 122]
18:[ 66  75 119 121]
19:[ 65  72  79 115]
20:[ 82 112 114 127]
21:[ 64  95  98 111]
22:[ 73  89  97 125]
23:[ 78  81  86 126]
24:[ 83  85 101 103]
25:[ 84  99 100 102]
26:[ 90  93 108 109]
27:[ 71  88  91 104]
28:[ 80  96 105 106]
29:[ 87  92 107 110]
30:[ 6 30 49 56]
31:[ 70  94 113 120]
32:[128 129 130 131]
33:[132 133 134 135]
34:[136 137 138 139]
35:[140 141 142 143]
36:[144 145 146 147]
37:[148 149 150 151]
38:[152 153 154 155]
39:[156 157 158 159]
chongxi commented 5 years ago
for i in range(30,40):
    prb.grp_dict.pop(i)

prb.show() works

chongxi commented 5 years ago

So the fix could be, put the prb.grp_dict.keys() into the json file

chongxi commented 5 years ago

Fix json save/load under python 3: (numpy.int is not serializable)

https://github.com/chongxi/spiketag/commit/03b876e6b7ee607461d709f988f3cc361db6ff95

chongxi commented 5 years ago

Test showed, prb file (JSON)

  1. can be save/load
  2. can be used under command spiketag fpga prb_file to sync with FPGA
  3. can be loaded by open-ephys channel mapping
  4. can be visualized and interacted (only the prb.grp_matrix, not the prb.mask_grp_matrix)