Raphaelle
(Raphaëlle LEROUX AUGER)
August 4, 2022, 9:04am
#1
Hi everyone,
I am having trouble passing head position to maxwell filter function.
I need it to concatenate data from each runs of my experience.
Here is the code I used :
noisy_chs, flat_chs = mne.preprocessing.find_bad_channels_maxwell(raw)
raw.info['bads'] = noisy_chs + flat_chs
raw.info['bads'] += bad_channels # bad channels from observation
head_position=input_raw.info['dev_head_t']
raw_pretreated = mne.preprocessing.maxwell_filter(raw, origin=(0., 0., 0.04), calibration=cal_fname, cross_talk=ct_fname, head_pos = head_position )
Error message : TypeError: head_pos must be an instance of ndarray or None, got <class 'mne.transforms.Transform'> instead.
The problem seems to be that raw.info[âdev_head_tâ] is not an array, but I couldnât find an appropriate method to convert it. Or maybe I am not using the maxwell filter function correctly?
Thank you in advance for your help !
richard
(Richard Höchenberger)
August 4, 2022, 1:50pm
#2
Hello @Raphaelle , and welcome to the forum!
info['dev_head_t']
is the device-to-head coordinate system transformation matrix, not the head positions.
Typically, head positions are loaded e.g. via the read_head_pos()
function.
But they can also be computed, please see this tutorial:
https://mne.tools/stable/auto_tutorials/preprocessing/59_head_positions.html
Best wishes,
Richard
Raphaelle
(Raphaëlle LEROUX AUGER)
August 5, 2022, 3:19pm
#3
Hi Richard, thank you for your answer.
I tried both methods, but couldnât do the first one (read_head_pos() function) because I donât have any separated file ending with .pos.
I tried to compute with the other method :
chpi_amplitudes = mne.chpi.compute_chpi_amplitudes(raw)
chpi_locs = mne.chpi.compute_chpi_locs(raw.info, chpi_amplitudes)
head_position = mne.chpi.compute_head_pos(raw.info, chpi_locs, verbose=True)
but the first function doesnât seem to work (it stays at â0%â step for several minutes, then it stops):
Using 4 HPI coils: 293 307 314 321 Hz
Line interference frequencies: 50 100 150 200 250 300 Hz
Using time window: 142.9 ms
Fitting 4 HPI coil locations at up to 75293 time points (753.0 sec duration)
0%| | cHPI amplitudes : 0/75293 [00:00<?, ?it/s]
At the end of the script, the variable âhead_positionâ is an empty array.
Do you have an idea of what is going wrong ?
(I precise we did use HPI during the acquisition)
Thanks in advance,
Bests,
Raphaëlle
richard
(Richard Höchenberger)
August 5, 2022, 4:15pm
#4
Which version of MNE is that? I think I read about a similar issue not too long ago and @larsoner fixed it in MNE 1.1, but I might be totally mistaken
Raphaelle
(Raphaëlle LEROUX AUGER)
August 5, 2022, 5:00pm
#5
I have the last version (MNE 1.1), and I work with a mac.