cortex-lab / Rigbox

A MATLAB toolbox for running behavioral neuroscience experiments and managing data
GNU General Public License v3.0
33 stars 16 forks source link

Error encoding dfilt.df2sos obj to JSON #233

Closed k1o0 closed 4 years ago

k1o0 commented 4 years ago

Occurs for mouse LEW032.

 Error using jsonencode
Unable to encode objects of class dfilt.df2sos as JSON-formatted
text.

Error in obj2json (line 9)
  s = jsonencode(s, 'ConvertInfAndNaN', true);

Error in srv.expServer/runExp (line 311)
    fprintf(fid, '%s', obj2json(rig));

Error in srv.expServer/handleMessage (line 231)
              aborted = runExp(expRef, preDelay, postDelay,
              AlyxInstance);

Error in srv.expServer (line 128)
    handleMessage(msgid, msgdata, host);
k1o0 commented 4 years ago

For prosperity, the problem is simply that someone saved some unwanted variables into the hardware file of a training rig:

 >> rig = hw.devices('ZYM3',false)

rig =   struct with fields:
                  Fs: 48000
                 ans: 6.1463e+03
        audioDevices: [1×10 struct]
                clkS: [8×12000 double]
           deviceIdx: 8
             devices: [1×9 struct]
                fBnk: [1×1 struct]
            hostname: 'Zym3↵'
                   i: -90
          mouseInput: [1×1 hw.DaqRotaryEncoder]
               nChan: 8
                pNoi: [8×480000 single]
            pahandle: 0
                sLab: [3 2 6 7 5 4 1 8]
             screens: [1×3 struct]
    stimViewingModel: [1×1 hw.PseudoCircularScreenViewingModel]
          stimWindow: [1×1 hw.ptb.Window]
            timeline: [1×1 hw.Timeline]
            wavedata: [8×12000 double]
               scale: [1×1 hw.WeighingScale]
       daqController: [1×1 hw.DaqController]
                name: 'ZYM3'
               clock: [1×1 hw.ptb.Clock]
              useDaq: 1
             GitHash: '87a5e1f8085c1779a9efa00fa0172aa213b6dc2a'
               paths: [1×1 struct]

The issue specifically is caused by the fBnk field:

>> rig.fBnk

ans = 

  struct with fields:

    sRsp: [7×26215 double]
    invF: [7×26215 double]
    sFlt: [7×257 double]
    fFrq: [1×26215 double]
    rndF: [100×101 double]
    cFlt: [1×1 dfilt.df2sos]
    wFlt: [1×1 dfilt.df2sos]
    rmsA: [2.4967 2.3047 2.4567 2.4686 2.4269 2.3180 2.5067]