Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Support TD data #11064

Draft
wants to merge 40 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
3f875d3
adding the new snirf data types to the constants
Zahra-M-Aghajan Aug 11, 2021
cc92adc
more places to add the data types and constants
Zahra-M-Aghajan Aug 11, 2021
0d2fe87
adding constants for the allowed dataTypeLabels for the processed dat…
Zahra-M-Aghajan Aug 11, 2021
21ecb90
updating the snirf reader to accept other data types: gated histogram…
Zahra-M-Aghajan Aug 11, 2021
4491064
setting the formatter line length
Zahra-M-Aghajan Aug 11, 2021
dbdcebc
the reordering of the channels does not make much sense, need to inquire
Zahra-M-Aghajan Aug 12, 2021
80de954
Merge remote-tracking branch 'upstream/main' into feature/TD-nirs_snirf
Zahra-M-Aghajan Aug 19, 2021
32c5496
Merge remote-tracking branch 'upstream/main' into feature/TD-nirs_snirf
larsoner Aug 21, 2022
a35822a
MAINT: Simpler with .item
larsoner Aug 21, 2022
c2c217c
WIP: Constants
larsoner Aug 21, 2022
ac52bc0
FIX: Flake
larsoner Aug 21, 2022
da275f1
FIX: Consistent
larsoner Aug 21, 2022
3986b96
FIX: Missed
larsoner Aug 21, 2022
ce8b3af
FIX: Better code
larsoner Aug 21, 2022
1244add
FIX: Scale
larsoner Aug 21, 2022
3944254
FIX: Missing
larsoner Aug 21, 2022
967dddd
FIX: Flake
larsoner Aug 21, 2022
e97367d
FIX: Syntax
larsoner Aug 21, 2022
4b963cd
Merge remote-tracking branch 'upstream/main' into feature/TD-nirs_snirf
larsoner Aug 23, 2022
15e2878
Merge remote-tracking branch 'upstream/main' into feature/TD-nirs_snirf
larsoner Mar 1, 2023
d26ff8a
FIX: shape
larsoner Mar 1, 2023
f84fe27
FIX: Slash
larsoner Mar 1, 2023
50f3064
FIX: Bad merge
larsoner Mar 1, 2023
495bdf7
Merge branch 'main' into feature/TD-nirs_snirf
larsoner Mar 2, 2023
a076e23
Merge remote-tracking branch 'upstream/main' into feature/TD-nirs_snirf
larsoner Mar 9, 2023
698d2a6
FIX: Add tests
larsoner Mar 9, 2023
d3b75ab
FIX: Reg
larsoner Mar 9, 2023
b1cf310
Merge branch 'main' into feature/TD-nirs_snirf
larsoner Mar 14, 2023
0c4f886
MAINT: Revert
larsoner Oct 28, 2024
34c36f5
Merge remote-tracking branch 'upstream/main' into feature/TD-nirs_snirf
larsoner Oct 28, 2024
b5e9967
Empty commit for credit
larsoner Oct 28, 2024
34dffbf
DOC: Change
larsoner Oct 28, 2024
d62dbb1
MAINT: Mailmap
larsoner Oct 28, 2024
880356e
FIX: SI
larsoner Oct 28, 2024
4f0e8e6
FIX: Oops
larsoner Oct 28, 2024
a5c97b8
FIX: Oops
larsoner Oct 28, 2024
fba1ffa
FIX: idx
larsoner Oct 28, 2024
9f4234d
WIP
larsoner Oct 28, 2024
b3b3f2e
FIX: Test
larsoner Oct 28, 2024
9723621
Merge remote-tracking branch 'upstream/main' into feature/TD-nirs_snirf
larsoner Oct 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -352,5 +352,6 @@ Yousra Bekhti <[email protected]> Yoursa BEKHTI <[email protected]
Yousra Bekhti <[email protected]> Yoursa BEKHTI <[email protected]>
Yousra Bekhti <[email protected]> Yousra BEKHTI <[email protected]>
Yousra Bekhti <[email protected]> yousrabk <[email protected]>
Zahra M. Aghajan <[email protected]> Zahra M. Aghajan <[email protected]>
Zhi Zhang <[email protected]> ZHANG Zhi <[email protected]>
Zhi Zhang <[email protected]> ZHANG Zhi <[email protected]>
1 change: 1 addition & 0 deletions doc/changes/devel/11064.newfeature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added basic support for TD fNIRS data, by :newcontrib:`Zahra Aghajan`, :newcontrib:`Julien Dubois`, :newcontrib:`John Griffiths`, `Robert Luke`_, and `Eric Larson`_.
3 changes: 3 additions & 0 deletions doc/changes/names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
.. _Joan Massich: https://github.com/massich
.. _Johann Benerradi: https://github.com/HanBnrd
.. _Johannes Niediek: https://github.com/jniediek
.. _John Griffiths: https://www.grifflab.com
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JohnGriffiths @julien-dubois-k @Zahra-M-Aghajan let me know if you want a different URL to link from your name in the changelog

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grifflab.com is perfect, thanks

.. _John Samuelsson: https://github.com/johnsam7
.. _John Veillette: https://psychology.uchicago.edu/directory/john-veillette
.. _Jon Houck: https://www.mrn.org/people/jon-m.-houck/principal-investigators
Expand All @@ -150,6 +151,7 @@
.. _Judy D Zhu: https://github.com/JD-Zhu
.. _Juergen Dammers: https://github.com/jdammers
.. _Jukka Nenonen: https://www.linkedin.com/pub/jukka-nenonen/28/b5a/684
.. _Julien Dubois: https://github.com/julien-dubois-k
.. _Jussi Nurminen: https://github.com/jjnurminen
.. _Kaisu Lankinen: http://bishoplab.berkeley.edu/Kaisu.html
.. _Katarina Slama: https://github.com/katarinaslama
Expand Down Expand Up @@ -314,5 +316,6 @@
.. _Yiping Zuo: https://github.com/frostime
.. _Yousra Bekhti: https://www.linkedin.com/pub/yousra-bekhti/56/886/421
.. _Yu-Han Luo: https://github.com/yh-luo
.. _Zahra Aghajan: https://github.com/Zahra-M-Aghajan
.. _Zhi Zhang: https://github.com/tczhangzhi/
.. _Zvi Baratz: https://github.com/ZviBaratz
28 changes: 27 additions & 1 deletion mne/_fiff/pick.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def get_channel_type_constants(include_defaults=False):
unit=FIFF.FIFF_UNIT_RAD,
coil_type=FIFF.FIFFV_COIL_FNIRS_FD_PHASE,
),
fnirs_td_gated_amplitude=dict(
kind=FIFF.FIFFV_FNIRS_CH,
unit=FIFF.FIFF_UNIT_V,
coil_type=FIFF.FIFFV_COIL_FNIRS_TD_GATED_AMPLITUDE,
),
fnirs_td_moments_amplitude=dict(
kind=FIFF.FIFFV_FNIRS_CH,
unit=FIFF.FIFF_UNIT_V,
coil_type=FIFF.FIFFV_COIL_FNIRS_TD_MOMENTS_AMPLITUDE,
),
fnirs_od=dict(kind=FIFF.FIFFV_FNIRS_CH, coil_type=FIFF.FIFFV_COIL_FNIRS_OD),
hbo=dict(
kind=FIFF.FIFFV_FNIRS_CH,
Expand Down Expand Up @@ -197,6 +207,8 @@ def get_channel_type_constants(include_defaults=False):
FIFF.FIFFV_COIL_FNIRS_FD_AC_AMPLITUDE: "fnirs_fd_ac_amplitude",
FIFF.FIFFV_COIL_FNIRS_FD_PHASE: "fnirs_fd_phase",
FIFF.FIFFV_COIL_FNIRS_OD: "fnirs_od",
FIFF.FIFFV_COIL_FNIRS_TD_GATED_AMPLITUDE: "fnirs_td_gated_amplitude",
FIFF.FIFFV_COIL_FNIRS_TD_MOMENTS_AMPLITUDE: "fnirs_td_moments_amplitude",
},
),
"eeg": (
Expand Down Expand Up @@ -385,6 +397,16 @@ def _triage_fnirs_pick(ch, fnirs, warned):
return True
elif ch["coil_type"] == FIFF.FIFFV_COIL_FNIRS_OD and "fnirs_od" in fnirs:
return True
elif (
ch["coil_type"] == FIFF.FIFFV_COIL_FNIRS_TD_MOMENTS_AMPLITUDE
and "fnirs_td_moments_amplitude" in fnirs
):
return True
elif (
ch["coil_type"] == FIFF.FIFFV_COIL_FNIRS_TD_GATED_AMPLITUDE
and "fnirs_td_gated_amplitude" in fnirs
):
return True
return False


Expand Down Expand Up @@ -569,7 +591,7 @@ def pick_types(
pick[k] = _triage_meg_pick(info["chs"][k], ref_meg)
elif ch_type in ("eyegaze", "pupil"):
pick[k] = _triage_eyetrack_pick(info["chs"][k], eyetrack)
else: # ch_type in ('hbo', 'hbr')
else: # ch_type in ('hbo', 'hbr', ...)
pick[k] = _triage_fnirs_pick(info["chs"][k], fnirs, warned)

# restrict channels to selection if provided
Expand Down Expand Up @@ -862,6 +884,8 @@ def channel_indices_by_type(info, picks=None):
fnirs_fd_ac_amplitude=list(),
fnirs_fd_phase=list(),
fnirs_od=list(),
fnirs_td_gated_amplitude=list(),
fnirs_td_moments_amplitude=list(),
eyegaze=list(),
pupil=list(),
)
Expand Down Expand Up @@ -1099,6 +1123,8 @@ def _check_excludes_includes(chs, info=None, allow_bads=False):
"fnirs_fd_ac_amplitude",
"fnirs_fd_phase",
"fnirs_od",
"fnirs_td_moments_amplitude",
"fnirs_td_gated_amplitude",
)
_EYETRACK_CH_TYPES_SPLIT = ("eyegaze", "pupil")
_DATA_CH_TYPES_ORDER_DEFAULT = (
Expand Down
12 changes: 12 additions & 0 deletions mne/cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,7 @@ def __init__(
grad=0.1,
mag=0.1,
eeg=0.1,
*,
seeg=0.1,
ecog=0.1,
hbo=0.1,
Expand All @@ -1529,6 +1530,8 @@ def __init__(
fnirs_fd_ac_amplitude=0.1,
fnirs_fd_phase=0.1,
fnirs_od=0.1,
fnirs_td_gated_amplitude=0.1,
fnirs_td_moments_amplitude=0.1,
csd=0.1,
dbs=0.1,
store_precision=False,
Expand Down Expand Up @@ -1908,6 +1911,7 @@ def regularize(
eeg=0.1,
exclude="bads",
proj=True,
*,
seeg=0.1,
ecog=0.1,
hbo=0.1,
Expand All @@ -1916,6 +1920,8 @@ def regularize(
fnirs_fd_ac_amplitude=0.1,
fnirs_fd_phase=0.1,
fnirs_od=0.1,
fnirs_td_gated_amplitude=0.1,
fnirs_td_moments_amplitude=0.1,
csd=0.1,
dbs=0.1,
rank=None,
Expand Down Expand Up @@ -1967,6 +1973,10 @@ def regularize(
Regularization factor for fNIRS raw phase signals.
fnirs_od : float (default 0.1)
Regularization factor for fNIRS optical density signals.
fnirs_td_gated_amplitude : float (default 0.1)
Regularization factor for fNIRS time domain gated amplitude signals.
fnirs_td_moments_amplitude : float (default 0.1)
Regularization factor for fNIRS time domain moments amplitude signals.
csd : float (default 0.1)
Regularization factor for EEG-CSD signals.
dbs : float (default 0.1)
Expand Down Expand Up @@ -2007,6 +2017,8 @@ def regularize(
fnirs_fd_ac_amplitude=fnirs_fd_ac_amplitude,
fnirs_fd_phase=fnirs_fd_phase,
fnirs_od=fnirs_od,
fnirs_td_gated_amplitude=fnirs_td_gated_amplitude,
fnirs_td_moments_amplitude=fnirs_td_moments_amplitude,
csd=csd,
)

Expand Down
12 changes: 12 additions & 0 deletions mne/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
fnirs_fd_ac_amplitude="k",
fnirs_fd_phase="k",
fnirs_od="k",
fnirs_td_gated_amplitude="k",
fnirs_td_moments_amplitude="k",
csd="k",
whitened="k",
gsr="#666633",
Expand Down Expand Up @@ -60,6 +62,8 @@
fnirs_fd_ac_amplitude="V",
fnirs_fd_phase="rad",
fnirs_od="V",
fnirs_td_gated_amplitude="M",
Copy link

@julien-dubois-k julien-dubois-k Nov 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are photon counts, should they be "AU"?

fnirs_td_moments_amplitude="M",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit weird, the dataType Time domain – Moments (TD Moments) - Amplitude can be any of the moments, which all have different units:

  • sum or intensity is photon counts
  • mean is s
  • variance is s^2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh... in this case we probably need to update the FIF "coil type" constants first since these are really sensing/detecting different sorts of data. Like we'll probably need:

  • td_moments_intensity (photon counts)
  • td_moments_mean (s)
  • td_moments_variance (s^2)

or similar

csd="V/m²",
whitened="Z",
gsr="S",
Expand Down Expand Up @@ -88,6 +92,8 @@
fnirs_fd_ac_amplitude="V",
fnirs_fd_phase="rad",
fnirs_od="V",
fnirs_td_gated_amplitude="µM",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update

fnirs_td_moments_amplitude="µM",
csd="mV/m²",
whitened="Z",
gsr="S",
Expand Down Expand Up @@ -117,6 +123,8 @@
fnirs_fd_ac_amplitude=1.0,
fnirs_fd_phase=1.0,
fnirs_od=1.0,
fnirs_td_gated_amplitude=1e6,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine this should be 1.0; same for fnirs_td_moments_amplitude

fnirs_td_moments_amplitude=1e6,
csd=1e3,
whitened=1.0,
gsr=1.0,
Expand Down Expand Up @@ -151,6 +159,8 @@
fnirs_fd_ac_amplitude=2e-2,
fnirs_fd_phase=2e-1,
fnirs_od=2e-2,
fnirs_td_gated_amplitude=1.0,
fnirs_td_moments_amplitude=1.0,
csd=200e-4,
dipole=1e-7,
gof=1e2,
Expand Down Expand Up @@ -206,6 +216,8 @@
fnirs_fd_phase="fNIRS (FD phase)",
fnirs_od="fNIRS (OD)",
hbr="Deoxyhemoglobin",
fnirs_td_gated_amplitude="fNIRS (TD amplitude)",
fnirs_td_moments_amplitude="fNIRS (TD moment)",
gof="Goodness of fit",
csd="Current source density",
stim="Stimulus",
Expand Down
Loading
Loading