-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ENH: Support TD data #11064
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
base: main
Are you sure you want to change the base?
ENH: Support TD data #11064
Conversation
…a type as outlined in the SNIRF specification document
…s, moments and processed (hbo/hbr)
Thanks for jumping in to finish this off @larsoner
Agreed Ping me when you want a review, it doesn't need to be a final review, I am happy to take a look early if that helps. |
Feel free to look now @rob-luke to see if you're happy with the overall design, the rest of the work is "just" some remaining details (adding unit tests, playing with the data a little bit to set scale factors, etc.) that I think we can rely on CIs to check, or that we can iterate on in follow-ups (e.g., tweaking plot scale factors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, it will be great to have support for TD in MNE! I will review again once there are tests.
* upstream/main: (264 commits) BUG: Fix deprecated API usage in example (mne-tools#11512) Deprecate 'kind' and 'path' in favor of 'fname' in the layout reader (mne-tools#11500) EGI/MFF events outside EEG recording should not break the code (mne-tools#11505) fixed annotations error on export (mne-tools#11435) DOC: Update installer links [skip azp] [skip actions] [skip cirrus] (mne-tools#11506) BUG: updates for MPL 3.7 compatibility (mne-tools#11409) Fix docstrings by replacing str with path-like and fix double backticks for formatting (mne-tools#11499) Use pathlib.Path instead of os.path to handle files and folders [circle deploy] (mne-tools#11473) MAINT: Fix Circle [circle deploy] (mne-tools#11497) MAINT: Use mamba in CIs (mne-tools#11471) Updating documentation to clarify full vs half-bandwidth and defaults in time_frequency.multitaper.py (mne-tools#11479) Fix typo in tutorial (mne-tools#11498) Typo fix and added colons before code (mne-tools#11496) [MRG] ENH/DOC: demo custom spectrum creation (mne-tools#11493) Accept only left-clicks for adding annotations (mne-tools#11491) [BUG, MRG] Fix pial surface loading, logging in locate_ieeg (mne-tools#11489) [ENH] Added unit_role to add non-breaking space between magnitude and units (mne-tools#11469) MAINT: Fix CircleCI build (mne-tools#11488) [DOC] Updated decoding.SSD documentation and internal variable naming (mne-tools#11475) Typo fix (mne-tools#11485) ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay code has been updated. I suspect the scaling could be wrong as I mention in a comment above ☝️ below 👇 but in any case people can test it with some data!
It's possible/likely that in addition to the possible scaling bug, we'll want to adjust the default plot scaling limits.
It would also be great to have an example added (maybe using mne-misc-data
) showing that this data can at least be read!
* upstream/main: eegbci api: allow downloading multiple subjects (mne-tools#12918) DOC: Document Linux desktop workaround (mne-tools#12900) Allow exporting edf where a channel contains only constant values (mne-tools#12911) Autogenerate environment.yml file from pyproject.toml (mne-tools#12914)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
confirming that the example runs here, and also that it seems to load other data files properly. the latter point I will can make and share a separate NB demonstrating that for 'peace of mind', in lieu of an analysis example discussed on the issue thread. Also noting that given @julien-dubois-k 's comment re some .snirf
attributes not being read, so those steps may also need to be added either to this PR or (probably better) a subsequent one. I will be looking at this next.
Afraid I don't know the answer to the uM units Q off hand.
@larsoner thanks for this. Have gone through, left review above. Not quite sure if I missed something specific other than the units Qs and the I don't not know to these off the top of my head, but I imagine @julien-dubois-k does. I can take a look at relevant documentation if that is useful. Re: datasets LMK if I have got this right re next steps
|
thank you @larsoner and @JohnGriffiths for your work pushing this PR
forward. I’ll review tomorrow and answer any remaining questions that I can
answer!
…On Wed, Nov 6, 2024 at 17:56 John Griffiths ***@***.***> wrote:
@larsoner <https://github.com/larsoner> thanks for this. Have gone
through, left review above.
Not quite sure if I missed something specific other than the units Qs and
the time_delay_widths Qs that you needed an immediate answer to; LMK
I don't not know to these off the top of my head, but I imagine
@julien-dubois-k <https://github.com/julien-dubois-k> does. I can take a
look at relevant documentation if that is useful.
Re: datasets
LMK if I have got this right re next steps
- You have two small .snirf files in the example data that is loaded
here so those aren't needed now for this test function
- But you are suggesting to add some other, larger files to
mne-misc-data for an analysis example (?)
- So, would you like me to do a PR to that repo with a .snirf data
file a a more fulsome analysis example?
- If so yes I can get on that. What I would do for the example code is
use the colab notebook example @julien-dubois-k
<https://github.com/julien-dubois-k> linked to in his above comment
<#11064 (comment)>,
and the example file the one used in that nb.
- ( I can add other finger tapping .snirf files to this if warranted )
- As I work on that I will take a look at the comments from
@julien-dubois-k <https://github.com/julien-dubois-k> noted in my
review comment above about some .snirf attributes not being read from
the .hdf properly by the mne reader. Which may lead to another
.io.snirf PR before the analysis example PR.
- But I think it's prob best not to muddy the current PR with that Q
(unless you disagree?)
—
Reply to this email directly, view it on GitHub
<#11064 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWIKIDKMADYHYTI6KHYECT3Z7LCGNAVCNFSM57FOV3OKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TENBWGEYTKNZRG44A>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Well related to the
Sure, then we modify an example here or more likely in
Sure if it adds something complementary from a documentation perspective. But if it's just additional subjects or a different paradigm from what we currently have, might not be worth it. (Just an aside, not sure if you've looked at mne-bids-pipeline but there is mne-tools/mne-bids-pipeline#365 that we could resurrect if you're interested in a BIDS pipeline for your data.)
I don't mind adding more stuff here, a +305/-85 PR is fairly small actually. So based on discussion I think the next steps would be:
|
Ok I'm on it.
Will do. What is the heuristic on acceptable size for a file in
So just temporarily change this requirements line to the commit url for the current PR, right?
That's great to know. thanks. We are actually currently in the process of getting an |
We try to keep our datasets to < 1GB if possible. Looks like
CircleCI is the CI that builds the doc so I would do it here actually |
I am a bit busy for the next two weeks but then should be able to come back to this! |
Okay two weeks turned into two months 😅 But I should be able to look next week |
* upstream/main: (149 commits) FIX make_watershed_bem to handle missing talairach_with_skull.lta courtesy Freesurfer 8 (mne-tools#13172) ENH: Add upsampling for MEG helmet surface (mne-tools#13179) MAINT: Update code credit (mne-tools#13180) BUG: Fix bug with least-squares sphere fit (mne-tools#13178) fix EDF export (mne-tools#13174) fix typo (mne-tools#13171) [pre-commit.ci] pre-commit autoupdate (mne-tools#13164) Fix dev installation guide (mne-tools#13163) expose 'mode' for plotting dipole on brain (mne-tools#13162) turn dipole attrs into properties (mne-tools#13153) remove misformatted (and unused) crossref anchor (mne-tools#13155) doc: point to read_dipole (mne-tools#13149) [pre-commit.ci] pre-commit autoupdate (mne-tools#13152) BUG: Fix bug with not short-circuiting n_jobs=1 (mne-tools#13147) FIX: Missing coordinates.xml in MFF file (mne-tools#13148) FIX: Gracefully handle bad XML files in EGI reader (mne-tools#13145) Fixes for Latest IPython (9.0.1) (mne-tools#13146) Fix intersphinx (mne-tools#13143) BUG: Fix bug with parallel doc build (mne-tools#13140) [pre-commit.ci] pre-commit autoupdate (mne-tools#13141) ...
mne/defaults.py
Outdated
fnirs_td_gated_amplitude="AU", # counts | ||
fnirs_td_moments_intensity="AU", # counts | ||
fnirs_td_moments_mean="s", | ||
fnirs_td_moments_variance="s²", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julien-dubois-k better? And in particular the S
you suggested for the unit is for Siemens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes these are good. s
is seconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hah, whoops! Will fix
Apologies for the embarassingly long delay on this one 🥵 Pushing some commits to make sure things are green, then I'll add the test files, etc! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julien-dubois-k okay I think I have it roughly where it could use another look from you to see if values are in the correct ranges, etc.!
_TD_MOMENT_ORDER_MAP = { | ||
0: "intensity", | ||
1: "mean", | ||
2: "variance", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@julien-dubois-k I just took a stab at this, not sure if it's actually correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
assert hbo_data.shape == hbr_data.shape == (shape[0] // 2, shape[1]) | ||
hbo_norm = np.nanmedian(np.linalg.norm(hbo_data, axis=-1)) | ||
hbr_norm = np.nanmedian(np.linalg.norm(hbr_data, axis=-1)) | ||
# TODO: Old file vs new file scaling, one is wrong! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to know if the numbers for the newer one are correct or not...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, what do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way the code works now the old test file and the new test file differ by several orders of magnitude (like 1e5) so I think there is uM vs M error scaling either in the file or in the code. Based on It looks like they should be closer to ~1e-6, right? If so then there is some bug in how we're reading the hbo/hbr values for the old file
# TODO: Reasonable values here??? | ||
lims = dict(intensity=(1e4, 1e7), mean=(1e3, 1e4), variance=(1e5, 1e7)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't know if these are reasonable values for the counts (intensity), mean (s), or variance (s**2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are reasonable if mean is in picoseconds and variance in ps^2.
fnirs_td_moments_amplitude=1e6, | ||
fnirs_td_gated_amplitude=1.0, | ||
fnirs_td_moments_intensity=1.0, | ||
fnirs_td_moments_mean=1.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the values are in the range of nanoseconds, so this should be 1e-9 for mean and 1e-18 for variance maybe?
Closes #9661
@rob-luke how about this plan:
.item()
instead of using_correct_shape
latest.inc
for this nice contribution (I'm just cleaning up really, you all did the hard work!)For now I'm inclined to make it so if you get a
SNIRF_PROCESSED
data type that we don't know how to handle, we should maybe raise an error in this case...? For now I've removed it as acoil_type
because this_PROCESSED
really seems to mean something else specific, and we should perhaps add those one by one as we find use cases for them.I have some collaborators who have seen Kernel help files telling them to use this very out of date branch, so it would be nice to get this in!