How do you extract data from a specific array?

ygreq's icon

Hi folks!

Any idea how I can extract the probability value from the following array?

I have a EEG headset and I am using node for max to extract some data from it. Here is the relevant js code:

let rightArmProbability;
neurosity.kinesis("rightArm").subscribe((intent) => {
  rightArmProbability = intent.predictions;
  maxApi.outlet("rightArmProbability", rightArmProbability);
});

And this is the data that is being outputted in the Max window. The attached image is what is being shown in the dict.view.

print: array: 

           label: rightArm

           metric: kinesis

           probability: 0.899373

           timestamp: 1726055665222

           type: training


           label: rightArm

           metric: kinesis

           probability: 0.883797

           timestamp: 1726055665347

           type: training


           label: rightArm

           metric: kinesis

           probability: 0.82849

           timestamp: 1726055665472

           type: training


           label: rightArm

           metric: kinesis

           probability: 0.792538

           timestamp: 1726055665597

           type: training


I tried everything from array objects to dict objects to select object. No results.

Any suggestions on what I should do?

Thank you so much!

TFL's icon

Your array ---> [array.iter] ---> [dict.unpack probability:]

ygreq's icon

Thank you, TFL!

BTW, I forgot to mention that the previous output is filtered with [route rightArmProbability]

So [node.script] -> [route rightArmProbability] and from here I put what you suggested.

Unfortunately I have no output. I see that dictionary u12120..2323 comes out of [route rightArmProbability] and goes to [array.iter] and then obj:dictionary:u8378237..3288 from there to [dict.unpack probability:]. But from there on there is no data

I will share the code, but I guess you might need the hardware as well.

JS Code attached in txt file.
And Max code:


Max Patch
Copy patch and select New From Clipboard in Max.


neurosity.txt
txt 5.28 KB

TFL's icon

Got it: the object you receive isn't an array but a dict with one key called array, in which is the actual array.

So you need to add a [dict.unpack array:] between your [route] and [array.iter].

No need for the hardware, just need the data it outputs.

Max Patch
Copy patch and select New From Clipboard in Max.

ygreq's icon

It works!!

Any idea on how to get all 4 probability values?

Anyway! Thank you so much!!

LE: I don't know if it is a but or not, but it seems it also works without the [array.iter]

And now I realize that I get all the 4 probability values. But I was curious on how to get them separately somehow to know which one is which.

Otherwise I might do a mean value calculation and work with that.

TFL's icon

Just passed by here randomly and realized I missed your last question. In case you still look for an answer, the most straightforward one would be [array.foreach].

Max Patch
Copy patch and select New From Clipboard in Max.

ygreq's icon

Thank you, TFL!!

Your previous answers helped a lot. Managed in the end.