This package computes the three dimensional spatial location for the center of the sensor cell for all OPMs whose positions are measured by a polhemus device. This is a necessary step in solving the forward problem.
test by running
python -m unittest test.test
from the root of this project folder, or run it as a module:
python -m opmpolhemus.sensors test/test_files/test01_raw.fif
To use this as a command line tool, first start a virtual environment with
python -m venv venv
and activate it with
source venv/bin/activate
Then, install the required packages with
pip install -r requirements.txt
python setup.py install
Now you can use this tool in the command line as:
python -m opmpolhemus.sensors $FILE_IN $FILE_OUT
where $FILE_IN
is the input file in .fif
or .txt
format, and the
$FILE_OUT
is the full path to the output file where the array of sensor
locations is written. For example:
python -m opmpolhemus.sensors test/test_files/test01_raw.fif out/test.txt
Or, to use this as a library in your Python project, install with
python setup.py install
Then import as:
from opmpolhemus.sensors import sensors
The package does require: mne
, numpy
, scipy
and matplotlib
. The mne
is required to accept fif
files.
The function sensors
accepts two required arguments: data, frame_style
. The data should for now be a .txt
file containing your
measurements in matrix form (only opm measurements) or a .fif
file containing the
digitization. The frame_style should be either top
or base
(see below for more info on that).
Both .fif
files and .txt
files are accepted as data
. When input is a
.txt
, it is assumed the input is a matrix of the HPI measurements, but only
the actual opm HPI measurements, so not including the fiducial points and the
indicator points (typically 4 and 3 respectively). For a .fif
file, nothing
extra needs to be done as the parser will itself only select the actual HPI
measurements.
The OPM device is the
QZFM Gen-2 produced by QuSpin. The
dimensions that are listed
here enter the code in
constants.py
.
For digitizing the points from which we compute the cell's locations, we use this device.
Currently, this cap is used. To digitize the location of the sensor, we tap specific points on or around the OPM. Currently, we accommodate two sets of specific points to tap, from which this program then computes the location of the sensor. Such a set of specific points will be called a frame, and the frames we allow for are dubbed: base and top, and are defined as follows:
<-------+ 16.6 +------->
OxxxxxO
^ +---------xxxxx---------+
| | |
+ O| |O
xx xx
12.4 xx z=1.5 xx
xx xx
+ O| |O
| | |
v +---------xxxxx---------+
OxxxxxO
frame=base. Dimensions are in millimeters.
In this diagram, an x
marks the location of the holder arms that are to
encapsulate the OPM
(see here).
These arms extend outward in direction normal to the screen.
The rectangle drawn by the -
lines and the +
on the corners is the base
frame that sits close to the scalp and is the resting frame of the OPM. Finally,
the eight O
points are the reference points that we mark with the polhemus.
With these measured points (N = 8 x # of OPMS
in total for frame=top) as input in the form of an
[N,3]
array, the location of the sensor within the OPM is computed for every
OPM. Because of the thickness of the base frame, the reference points O sit
slightly higher (1.5mm
) than the OPM bottom, as noted in the diagram.
<-------+ 16.6 +------->
xxxxx
^ +---------xxxxx---------+
| |O O|
+ | |
xx xx
12.4 xx z=24.0 xx
xx xx
+ | |
| |O O|
v +---------xxxxx---------+
xxxxx
frame=top. Dimensions in millimeters.
For this frame style, we mark only the four top corners of the OPM, at the top
face of the OPM at z=24mm
. These are four points, obviously. As there is not
real firm fixed base the polhemus style can rest on for this method, we advise
to do this measurement twice, that is, to go clock-wise and perform a total of
8
measurements, tapping every corner twice. The program will recognize this
and average over very nearby points (also for the case of accidental
double-clicks).