PDA

View Full Version : OT: time for another update (and some about programming)



Evan
11-18-2016, 10:41 PM
It is about time I showed where I am going on the neurology lab project. I have been making some real progress, finally. I have the Ruby language pretty well worked out but that sure wasn't easy. I have read that leaning a programming language is treated by the brain pretty much the same as learning any foreign language. You have new vocabulary to learn and the meanings of all that vocabulary must be known and understood precisely. Fortunately I am pretty good at foreign languages and speak several. This is just another in my collection I guess. The only real difference is that you don't need to verbally speak it. However, it does require an intuitive understanding of pure logic, something I have had since I was very young.

The project is now to a point where it meets an international standard for electrode placement, the 10-20 Standard. That is when the entire set of 64 electrodes isn't used so a wider spacing is used, 10 percent of head diameter horizontally around the head and approximately 20% of estimated vertical "diameter". This gives an approximate hexagonal spacing which is also used in much smaller spacing for the full 64 set. By doing it this way what is seen is the same as the full set but with lower resolution.

This video is showing real data from a very real person. In the video the first burst is about half normal brain speed. The second play is about 20 times slower than real life. It amazes me how fast we think. In the past I and most others thought that making a decision was something we pondered for at least a few seconds and maybe even minutes. It isn't that way at all. When we make a decision it is in milliseconds, maybe 50 to 100 ms at most. Our internal clock speed is far higher than was ever realized in the past. Then we think about the decision we made but it is already very firmly said and done in the mind even if it doesn't feel that way. At least that is my current understanding of what they are finding. There are so many new things we are discovering about how our brains really work.

That is one of the main reasons for this project. Another is that this presentation makes it far easier to see how the signals travel around in the brain since my model is full 3D. By slowing it way down it is so cool to see how the patterns shift across the brain as the thoughts travel around. I'm afraid I didn't record it really slow enough to see that properly, the video is already 9 megabytes as it is. I can't get away with really compressing it much because it really trashes the quality due to the use of fairly pure colour regions.

My app is now at what I consider to be much closer to a professional level with a number of user controls that are easy to use and understand. I still have a lot of work to do but much of that is just tedious "more of this and more of that" to make it a 64 channel system. I will also be meeting soon with the other lab partners once they finish the renovations on the lab meeting space and I see the professor again at the end of next week. It is time to set some basic standards for data formats and to listen to ideas others may have about what they might like to see.

I don't trust myself when it comes to how a computer system app looks to a regular user. They don't think like I do and I sure don't think like them.

As before I will not be leaving this posted for very long, a few days at most. At 9 megs this is going to load my server a lot.

http://ixian.ca/server/nov18-2016-EGWv4d.avi

BTW, The Ruby language sure isn't like what I was expecting. It does things the "new way". There is a lot of "imprecision" in how it works. It makes a lot of guesses about what you want. Also, the meaning of "assignment" has changed a lot. The way values are assigned is totally backwards from what I am accustomed to.

If I write this "new_color = entities.add_color( [0,0,0], [255,255,0])", I don't care about the variable new_color. It is the numbers on the right that I am assigning to the system. Not how I am used to thinking about assignment, that's for sure. The variable "new_color" can be whatever I want. It doesn't matter.

The video is an avi format this time so it should display on anything. Here is a still pic of how it now looks. Many controls as well as a memory function to remember how the user wants it to come up each time they use it. Everything is hideable or can be made dimmer so it doesn't distract from the display. Speed of display is very controllable from near full speed of half a second to half a minute. I give full credit to the professor because this was his idea, not mine. That can also be tucked away as an "About" function. I will most likely also add some nice color sliders to adjust the color although the prof really likes these. It will also create a new graph every time new data is used.

The brain model itself also changes grey scale intensity in time with the total absolute average of all sensors. That looks really cool and helps illuminate the colors at the right times since they are partly transparent (turned off in the video but it shows above the graph). The numeric values are not yet done so they are static. The moving line on the graph was a challenge to avoid slowing down the system but I figured out a way to do it that doesn't slow it down at all. That was not easy. System speed is the most important factor of all.

http://ixian.ca/pics12/Nov18-2016EGW.jpg

I am also including digital frequency filters so the value changes can be smoothed to whatever degree the user wants. I have written that already but it isn't set up at the user level yet.

fixerdave
11-19-2016, 01:43 AM
... If I write this "new_color = entities.add_color( [0,0,0], [255,255,0])", I don't care about the variable new_color. It is the numbers on the right that I am assigning to the system...

Just calling a method in the object 'entities' with the results of that call getting dumped into new_color. Looks like a couple of color values getting added to an array... but that's a guess. Just think of it as a function/routine with its own stack of variables inside a big array of the object type. Okay... that probably didn't help :confused:

If you want weird, you should try object oriented code in Perl, which is weird all by itself even without adding the object weirdness.

Nice video... I'll assume the graph on the right is basically a stacked bar combining all the zones over time. I'll wager the people that created SketchUp never thought their system would be used quite like this... but that is the power of an API. Never quite know what somebody will dream up.

So, now that you're a Ruby expert... what other plugins are you going to make? Do you have a list or are you still too eyeball deep in this project to think about what comes next?

David...

Evan
11-19-2016, 02:57 AM
I have way too much going on right now but I am going to write some plugins when I have time. I have been doing various workarounds to make this work fast enough and so far all is good enough. The bar on the graph is just a bunch of layers that are made visible or not in sequence. It turns out to be extremely fast and at the end of doing the channel data one full pass I call Sketchup.active_model.active_view.refresh . That unconditionally refreshes the screen no matter what else is happening. There are also some big differences on what sort of variables you use as far as time and also the frequency of garbage collection. I can easily see the GC when it happens because it causes a tiny pause in the moving graph line. That makes a nice little monitor for the GC routine.

One thing I quickly discovered about the layers is that the assigned layer numbers are meaningless if you delete any layers in the middle somewhere. It counts the actual layers in sequence starting from one, not zero since zero is the default layer for all items. Remove layer one or any higher one and all the rest above that move down by one inside no matter what it says they are. That became a major PITA in a hurry. If you add any layers they automatically go to the lowest empty one. Then if you rename them it will move them to the top of the stack but the numbers still don't match. I must keep exact track of how many there are and how many are not present and where they are in the hidden sequence numbers.

One major issue I have right now is the time delay I need to change the display time. The sleep command is useless. It behaves strangely with floating point, not quite like integers but also not pure floating point. It has some sort of fractions going on. If you call sleep with a zero it takes no time at all but if you call it with even a tiny fraction it takes a lot of time. Then increase the tiny fraction and after a few changes it jumps an unpredictable amount. Right now I am just making it do something that takes a lot of time but that is totally dependent on CPU speed. Not good enough. I think I will figure out some way to calibrate the CPU and then I will have some clue what time it takes.

The biggest problem is I cannot do anything that involves the local operating system, no Windows API calls allowed since it must run on a Mac.

I like writing in assembler. Then you have total control of everything.

Oh, a bit off topic but I rode my bike to the hospital yesterday and had a standard Complete Blood Count (CBC) blood test done (again and again...). For the first time in many years my platelets are finally up into the normal range. They have climbed by close to double of what they have been in the past. That means far lower chance of another hemorrhagic stroke. I like that a lot.

fixerdave
11-19-2016, 03:53 AM
...The bar on the graph is just a bunch of layers that are made visible or not in sequence
...
One thing I quickly discovered about the layers is that the assigned layer numbers are meaningless
...
One major issue I have right now is the time delay I need to change the display time. The sleep command is useless. ...

Using layers... Sneaky :)

I've never done anything in Ruby but I have learned over years of toying with other people's Object Orientated (OO) libraries is that it really helps to figure out how to query and display all the methods in an object. Very (very) often, the documentation offered leaves out a lot of really useful stuff. Seeing the methods and then experimenting with them is sometimes the only way to figure it out.

As for delays, have you tried this (just a quick google search):
http://docs.rubygame.org/rdoc/2.5.0/classes/Rubygame/Clock.html
Sounds like what you need.

Another thing I've learned is that, as much as it pains me to even look, somebody has probably already done what I need. There are libraries for just about everything. Maybe, in a year or so, there will even be a library to model sensors on a brain, or maybe a library to show a vertical progress line on a graph... assuming a guy named Evan writes it ;) Coding these days is a long, long way from a guy building up his own toolkit in assembly. Lots of sharing going on.

David...

Evan
11-19-2016, 04:05 AM
The documentation generally sucks. People have tried hard but they haven't made it. A big issue with the Sketchup docs is every single doc example assumes you make something and then do something with what you just made. That isn't what I need. I need to know how to get in the same field of what I have already made somewhere else. It is finally making sense now but it sure took a while. Part is just that my brain is getting old, I am sure. A bit of damage along the way sure hasn't helped either.

Thanks for the link. Looks like what I need.

fixerdave
11-19-2016, 04:19 AM
...
Thanks for the link. Looks like what I need.

Being SketchUp, there may not be a way to install this (or you may not want your stuff to require everyone running it to preload another library). It's best to make it work as designed, and it may flow beautifully, but it might not. Even then, all is not lost.

I have, at least in Perl, just grabbed an opensource library and ripped out the bits I need, incorporating them directly in my code. Not the prettiest way to do it, and I did try to give credit where due, but sometimes you have to go the long way around.

Just sayin...

David...

aostling
11-19-2016, 10:10 AM
I am unsure of the meaning of the colors displayed. The graph appears to associate red with a high positive ampliture, yellow with zero, and green with negative amplitude. But the colors on the 3D head sometimes go brown, and blue. A color chart, showing what each shade means, might be useful.

Evan
11-19-2016, 12:27 PM
That will depend on the prof. He is impressed by it and has specifically mentioned this. The statistical significance of the colours is important but only if it is accurate enough. This is something I worked with much of my life and accurate colour rendition is nearly impossible to achieve regardless of the methods used. Every method we use from printed to painted to computers is different. Every method has its limits and nearly all methods are far more limited than the human eye and our ability to perceive colours, and those are all different too. Just with computer screens the gamut is far more limited and then the software makes it even more limited and that includes the various operating systems. I have a great deal of training in this because it was my day job for a long time. What you see on your screen is not the same as mine.

I wrote a short article and instructions about how to correctly balance a monitor when I was a tester for JASC software. It is still online on my server so if interested see here:

http://vts.bc.ca/color.htm

Note that I wrote this before flat screens were the soup of the day. That is still changing now with OLED monitors such as on my Samsung tablet.


But the colors on the 3D head sometimes go brown, and blue.

Yep. I only have three colours to play with, red, green and blue. They aren't mixed on the screen either, just next to each other. They don't all have the same gain and even if they did it isn't linear with brightness (luminance) change. Flat screens still aren't as good as a high quality CRT. Flat screens are very limited at low intensity where they become very non-linear. In the lower half of the intensity range the so called 16 million colours is far more limited in a digital system since you are then down to maybe only 4 bits of difference, not 8.

(examples keep popping into my head) On my digital sound system the volume control is a good example. When I want to turn down the sound to a very low level the very low part of the volume knob makes large differences near the bottom of the range. That is the digital distortion coming into play by only having a few bits of difference to play with.