Skip to content

Let pybv write [coordinates] section to vhdr files #44

@sappelhoff

Description

@sappelhoff

See BrainVision data file specification.

The OPTIONAL [Coordinates] section in a vhdr file comes right after the REQUIRED [Channels] section, and it looks like this:

[Coordinates]
; Each entry: Ch<Channel number>=<Radius>,<Theta>,<Phi>
Ch1=1,-60,-51
Ch2=1,-49,-29
Ch3=1,-45,0
Ch4=1,-49,29

For the radius, the spec say the following [emphasis by me]:

“The radius r specifies the distance (in millimeters) between point P and the origin of the coordinate system. The only exceptions are r = 0 and r = 1. r = 0 signifies an invalid position, for instance when the position of an electrode is not known. When realistic electrode coordinates are used, r can have a different value for each channel. In other cases, the value of r should be the same for all the channels if a spherical head model is used. For instance, in the Analyzer's standard coordinate system, r = 1”.

All coordinates that pybv writes to the [Coordinates] section must first be transformed to the Analyzer's standard coordinate system, which happens to be the CapTrak system (more info in FieldTrip wiki). For this conversion to work, we will need the Nasion, left, and right preauricular point coordinates (to rescale the coordsystem).

I suggest that furthermore, pybv writes a more extensive comment in the [Coordinates] section:

[Coordinates]
; Each entry: Ch<Channel number>=<Radius>,<Theta>,<Phi>
; Radius defined in millimeters (mm).
; Radius of 0 signifies invalid position for a given electrode.
; If all coordinates are on an (idealized) spherical head model, Radius will be 1 for all entries.
; The coordinate system is "Captrak", see definition of axes below.
; The X-axis goes from the left preauricular point towards (through) the right preauricular point.
; The Y-axis goes orthogonally to the X-axis and towards (through) the nasion.
; The Z-axis goes orthogonally to the X-Y-plane upwards.
; Below are the coordinates for left and right preauricular points, and the nasion.
; LPA=1,44,55
; RPA=1,44,55
; Nasion=1,44,55
Ch1=1,-60,-51
Ch2=1,-49,-29
Ch3=1,-45,0
Ch4=1,-49,29

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort:mediumestimated medium effort taskenhancementNew feature or requestimpact:mediumestimated medium impact task

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions