Back to the main page.

Bug 1644 - optional display of dewar/sensors in combination with realtime MEG headlocalizer

Reported 2012-08-10 11:00:00 +0200
Modified 2019-08-10 11:56:31 +0200
Product: FieldTrip
Component: realtime
Version: unspecified
Hardware: PC
Operating System: Mac OS
Importance: P3 normal
Assigned to: Arjen Stolk
Depends on: 1726
See also:

Robert Oostenveld - 2012-08-10 11:00:27 +0200

For a MEG guidelines paper we received the following suggestion from a reviewer. > * Recommend to use software which shows the head position with > respect to the dewar right after the HPI measurement to ensure correct positioning. > Reply: Thanks for this comment. This statement has been added on page 6. It is a good idea as sanity check. I propose to make it optional (perhaps even with a button in the RT figure [*]) to switch on/off the channel positions. That allows the user to validate that the head is in an appropriate position. We might also want to change the head that is displayed to be more realistic. @Eelke: *] The idea of the button follows the discussion in the FT meeting on wednesday. We can in principle for all GUIs consider which keyboard buttons have a role, and whether those should also be added to the figure itself. Just like the "q" button which is used in quite a few plots.

Arjen Stolk - 2012-08-10 12:10:40 +0200

Yep, that'd be cool. Although I can see it may be dysfunctional as well, so the option to switch it on/off would be a must.

Robert Oostenveld - 2012-08-10 12:51:00 +0200

I recall there is a "reset" key that can be pressed. I would imagine a similar key being defined to toggle the visibility of the MEG channels (ft_plot_sens). We might want to improve ft_plot_sens to show actual coils, rather than points. The keyboard shortcuts (also "q" to quit?) could be added to the GUI as buttons.

Arjen Stolk - 2012-08-10 12:57:15 +0200

Right now, there's an 'update' key (U) reflecting the updating of reference positions to that of the current/realtime position. We could make a similar one for showing the sensors. Would it be nice to have a transparant dewar/sensor surface?

Robert Oostenveld - 2012-08-10 13:14:30 +0200

We don't have a dewar surface description, nor a realistic head surface. I was first only thinking of plotting the MEG coils. Getting the CTF275 dewar surface coregistered properly would require some lab work (Lucia and Gareth at FIL/UCL have a scanned version, but that won't be coregistered). Initially the coils should be enough.

Arjen Stolk - 2012-08-10 14:58:11 +0200

Oki doki!

Arjen Stolk - 2012-08-14 22:23:39 +0200

With respect to the 'q' button to quit the application; do you know of way to effectuate a 'ctrl+c' operation in the matlab command window? This is how the buffer application is stopped now. I'm thinking in terms of eval('CTRL+C')..

Robert Oostenveld - 2012-08-14 22:44:24 +0200

to be discussed tomorrow

Robert Oostenveld - 2012-08-15 09:13:32 +0200

I suggest to use a piece of code like this % read the template coil positions if ~isempty(cfg.template) template = ft_read_headshape(cfg.template, 'coordinates', 'dewar'); transform_dewar2head = headcoordinates(nas, lpa, rpa, 0); % the flag 0 means CTF transform_head2dewar = inv(transform_dewar2head); else template = []; transform_dewar2head = eye(4); transform_head2dewar = eye(4); end and then use ft_warp_apply

Robert Oostenveld - 2012-08-15 09:40:01 +0200

See the following for examples on dealing with key presses in a figure manzana> grep -i KeyPressFcn *.m ft_analysisprotocol.m: set(fig, 'KeyPressFcn', @key); ft_databrowser.m:set(h, 'KeyPressFcn', @keyboard_cb); ft_multiplotTFR.m: set(gcf, 'KeyPressFcn', {@key_sub, zmin, zmax}) ft_singleplotER.m: set(gcf, 'keypressfcn', {@key_sub, xmin, xmax, ymin, ymax}) ft_singleplotTFR.m: set(gcf, 'KeyPressFcn', {@key_sub, zmin, zmax}) ft_topoplotTFR.m: set(gcf, 'KeyPressFcn', {@key_sub, zmin, zmax})

Arjen Stolk - 2012-08-20 10:51:24 +0200

Added gui environment and key- and buttonpress callbacks to display the sensors(s), update the references (u), and to stop the application (q), and a couple more. See revision 6380 and younger.

Robert Oostenveld - 2012-08-22 11:13:04 +0200

Should we also add the block size to the GUI? People might want to update it online.

Arjen Stolk - 2012-08-22 11:19:44 +0200

Yep, good idea. (In reply to comment #11)

Robert Oostenveld - 2012-08-22 12:17:27 +0200

see comment #12

Arjen Stolk - 2012-08-22 15:06:13 +0200

btw, we need to deal with the issue that the grad field and the orig.hc field are not accompanied with the hdr information when transmitted over the buffer. this blocks us, at the moment, from plotting the sensors when real-time.. (In reply to comment #13)

Robert Oostenveld - 2012-08-22 16:02:58 +0200

(In reply to comment #14) please determine what is passed along. Perhaps you can store the output of ft_read_header on the buffer in a mat file so that we can look at it offline. The section of ft_read_header line 921 is the relevant part. Btw. I dont think that the hc is possible in any way for online, but the res4 should have something useful in it.

Robert Oostenveld - 2012-09-20 09:48:24 +0200

The FT_CHUNK_CTF_RES4 should allow for the full channel details to be transmitted over the network. See Perhaps it does not work in our MEG lab because an old implementation (~2009 or 2010) seems to be used. See also bug #1726

Arjen Stolk - 2012-12-05 10:42:16 +0100

It turns out that the 'res4 chunk' was not present in the header because acq2ftx did not write it. The solution is to have aq2ftx write it by specifying the additional 'R' flag when calling acq2ftx: acq2ftx -:1972:GR:1:*

Arjen Stolk - 2012-12-05 10:48:05 +0100

improved chunk handling when reading roboos@lab-pre042> svn commit Sending fileio/ft_chantype.m Sending fileio/ft_read_header.m Transmitting file data .. Committed revision 7088.

Arjen Stolk - 2012-12-05 10:48:58 +0100

It turns out that the 'res4 chunk' was not present in the header because acq2ftx did not write it. The solution is to have aq2ftx write it by specifying the additional 'R' flag when calling acq2ftx: acq2ftx -:1972:GR:1:*

Arjen Stolk - 2012-12-05 11:04:57 +0100

TODO: rename sap2matlab into decodesap

Arjen Stolk - 2012-12-05 11:14:05 +0100

roboos@lab-pre042> svn commit Sending fileio/ft_read_header.m Adding fileio/private/decode_res4.m Transmitting file data .. Committed revision 7089.

Robert Oostenveld - 2012-12-05 12:29:44 +0100

(In reply to comment #20) I checked sap2matlab: it is a mex file, so better don't touch it.

Arjen Stolk - 2012-12-05 18:17:12 +0100

realtime plotting of MEG (CTF) sensors now is functional

Arjen Stolk - 2012-12-05 20:12:44 +0100

Note that in order to plot the sensors, the sensor information needed to be made available though the buffer, independently from any other files. ft_read_header therefore was adjusted so that it also reads the additional header chunk (see earlier comment). For efficiency purposes, this needs to be done once when the additional header chunk is not updated. ft_reader_header incorporates this intelligence.

Robert Oostenveld - 2019-08-10 11:56:31 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on