Skip to content

ENH: filtering and apply_function for Raw - #27

Merged
agramfort merged 4 commits into
mne-tools:masterfrom
mluessi:raw_apply
Mar 5, 2012
Merged

agramfort merged 4 commits into
mne-tools:masterfrom
mluessi:raw_apply

Conversation

@mluessi

@mluessi mluessi commented Mar 2, 2012

Copy link
Copy Markdown
Contributor

Adds low-pass, high-pass, and band-pass filtering to Raw. The filtering operations use the new Raw.apply_function interface, which enables efficient parallel application of functions to a subset of channels.

@agramfort: Since the analytic signal is complex, I haven't added an "apply_hilbert" function so far. At the moment, Raw._data remains float32 regardless of the data type the function returns. We could convert the data type of Raw._data if necessary, but it may then no longer be possible to save the Raw object to a fiff file (does fiff support complex raw files?). If saving to .fiff is no longer possible we could issue a waring.

@dgwakeman

Copy link
Copy Markdown
Contributor

This question has come up before (I asked Matti a month ago). Fiff
supports complex numbers; however, the mne compiled binaries do not, so
you would not be able to use it in mne_compute_raw_inverse (for
example). You would though be able to read an inverse solution into
MATLAB/OCTAVE/PYTHON and use the complex fiff file there. If you are
interested in adding this, you could add a warning at saving, and
possibly add (or have Matti add) a check with warning for the
appropriate compiled software.

D

Martin Luessi wrote:

Adds low-pass, high-pass, and band-pass filtering to Raw. The filtering operations use the new Raw.apply_function interface, which enables efficient parallel application of functions to a subset of channels.

@agramfort: Since the analytic signal is complex, I haven't added an "apply_hilbert" function so far. At the moment, Raw._data remains float32 regardless of the data type the function returns. We could convert the data type of Raw._data if necessary, but it may then no longer be possible to save the Raw object to a fiff file (does fiff support complex raw files?). If saving to .fiff is no longer possible we could issue a waring.

You can merge this Pull Request by running:

git pull https://github.com/mluessi/mne-python raw_apply

Or you can view, comment on it, or merge it online at:

#27

-- Commit Summary --

  • ENH: filtering and apply_function for Raw

-- File Changes --

M doc/source/whats_new.rst (1)
M mne/fiff/raw.py (161)
M mne/fiff/tests/test_raw.py (32)

-- Patch Links --

https://github.com/mne-tools/mne-python/pull/27.patch
https://github.com/mne-tools/mne-python/pull/27.diff


Reply to this email directly or view it on GitHub:
#27

@mluessi

mluessi commented Mar 2, 2012

Copy link
Copy Markdown
Contributor Author

Ok, I implemented reading/writing of complex raw files. It works but I still need to clean up the code a bit..

Comment thread mne/fiff/raw.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You should use iscallable. It is more pythonic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

surely you mean "callable" ;-) , done

@agramfort

Copy link
Copy Markdown
Member

Apart from that that's great!

Comment thread mne/fiff/raw.py Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i feel we should call it apply_hilbert to match the apply_* API

Comment thread mne/fiff/raw.py

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you add a note that n_jobs > 1 will require more memory?

@agramfort

Copy link
Copy Markdown
Member

apart from this nitpicking I am super happy about this new feature !

agramfort added a commit that referenced this pull request Mar 5, 2012
ENH: filtering and apply_function for Raw
@agramfort
agramfort merged commit be3a06a into mne-tools:master Mar 5, 2012
@agramfort

Copy link
Copy Markdown
Member

Merged :)

larsoner added a commit that referenced this pull request Nov 20, 2020
…ast signal (#7717)

* debugged import function, plotting locations kinda works, dists calculate, data flat

* fixed name for return in utils.py

* extra newline in boxy.py

* fixing newlines

* removed call to findfiducials

* removed mne calls

* revert to import mne to debug data

* working data load and plot, needed to divide expected data by 16 for each source

* pull sorce number from code

* working plotting with rescale

* fixed import of coreg function

* removed transform into fsaverage since it already was there

* working through bug plotting dig

* working example

* working version that loads in coordiantes and transforms correctly

* fixed review comments

* created gratton_emcp_epochs function in preprocessing/eog.py

* revert commit to master

* fix

* revert

* fix

* space
;

* initialize new branch with boxy.py file and folder in io with tests

* fixing eog nonchange

* fix

* fix

* rebase fix?

* fix?

* added dataset import information

* updated dataset stuff

* correct  hash from osf

* working data load

* debuging loading file

* debugged import function, plotting locations kinda works, dists calculate, data flat

* fixed name for return in utils.py

* extra newline in boxy.py

* fixing newlines

* removed call to findfiducials

* removed mne calls

* revert to import mne to debug data

* working data load and plot, needed to divide expected data by 16 for each source

* pull sorce number from code

* working plotting with rescale

* fixed import of coreg function

* removed transform into fsaverage since it already was there

* working through bug plotting dig

* working example

* working version that loads in coordiantes and transforms correctly

* fixed review comments

* created gratton_emcp_epochs function in preprocessing/eog.py

* revert commit to master

* fix

* revert

* fix

* space
;

* rebase from import to fix pandas use

* filetype now determined in RawBOXY and passed to _read_segment_file. Changed subjects_dir to use fetch_fsaverage as I was getting errors about surfaces or fiducial files missing

* removed pdb

* new data file with more files

* tested new dataset, added four new keys for four montages, and testing loading in each one in place of 001

* pulling in source detector plotting temporarily

* WIP trying to load multiple boxy files

* seems to be working...will find multiple files and combine all the data into a large array, with marker info added to the end from each file

* boxy.py now takes a datatype arguments to return only AC, DC, or Ph data

* changed tutorial to plot montage a and b

* updated dataset P1 with arr

* added new dataset with better variable names, removed look for .tol file

* made some changes based on comments. re-organised channels so lower wavelength is first, to keep scalp_coupling_index happy

* pushed the wrong tutorial file, this should fix that

* style changes for flake8 on boxy.py

* tested parsed data set, channel numbers considered across all montages, added messages indicating data size for all blocks and montages

* blocks are now appended together, so data is now n channels by (m timepoints x b blocks). removed block and montage indicators from channel labels, and change plot_80 tutorial to take the label changes into account

* added markers to indicate the end of each block. will also check for event files and place those in the marker channels, if the files exist

* marker channel kind is now stim instead of fnirs_raw, coords are no longer transformed

* went through entire boxy tutorial to create and compare epochs

* added a few messages to print if markers are found or not, for each montage and block

* updated dataset

* marker times were off, had to change so first_samp and last_samp refer to sample number in the data structure, not lines from the file

* phase data will be unwrapped, detrended, and outliers removed

* added conversion of phase to pico seconds

* initial push to create PR

* tutorial will now combine montages and plot results of this combination

* added wrong file to earlier commit

* working on adding two new data types, fnirs_ac and fnirs_ph

* made test script in temporary dev folder

* phase data will be unwrapped, detrended, and outliers removed

* added conversion of phase to pico seconds

* working on adding two new data types, fnirs_ac and fnirs_ph

* made test script in temporary dev folder

* all plots except haemo should now be able to handle fnirs_ph, might not need all of them though

* changed ph default scale

* removed some commented code

* added sections to plot both AC and Ph data

* changed time scale of ac data to 10 sec, replaced raw ac with haemo for plotting

* now only plots AC haemo and phase data. Cleaned up formatting

* plot_80 and boxy.py should now hopefully conform to pep8

* fixed flake8 on boxy.py

* flake8 on other files

* removed dev folder

* a few more

* only combined montages plotted, scales have been adjusted, fixed change in optical density

* in progress changes for testing

* further changes for tests

* fixed some apparent style issues, removed print statements added previously

* more fixes, and removed forgotten print commands

* fixes for style and CI tests

* start of making the tutorial a bit more simple

* removed some plots to keep total under 20, and keep CI test happy

* changed filter settings so an error is not returned

* quick change to see if comment characters change html test

* testing out a method of plotting hbo and hbr evoked

* added more to difference evoked subplot, fixed a missing variable

* removed code for older plots

* missing blank line at end of eog.py

* removed stray print statement

* made sure files are sorted in the correct order

* made changes for checklist

* table of contents should now display properly

* added references, and description, of boxy example dataset

* fixed style issue in plot_80

* addressed some checklist items

* updated info about boxy dataset

* should now only read in boxy data file (#26)

* should now only read in boxy data file

* added tutorial and test for loading boxy data, remove plot_80 tutorial and reference for now

* now will only load a single boxy file

Co-authored-by: Kyle Mathewson <[email protected]>

* Events from raw data file are added as annotations (#27)

* events from raw data file are added as annotations

* ignores conssecutive trigger repeats in digaux, added tests for filetypes and digaux

* fixed some typos

* fixed more spelling and style errors

* changed filenames to match testing data set (#29)

* changes to make ci tests happy

* removed print statements and references to old dataset

* removed extra blank space

* Addressing reviewer comments (#30)

* addressing comments

* addressed more comments. Reader will return all data types

* removed reference to fnirs_fd_phase

* removed reference to degrees for fnirs_fd_phase

* added line to return channel type

* working through review

* fixed indent bug

* adding new channel info throughout codebase

* fixing merging errors

* FIX: Fix constants, reading, tests

* ENH: Efficient read

* Update tutorials/io/plot_30_reading_fnirs_data.py

Co-authored-by: Robert Luke <[email protected]>

* Update tutorials/io/plot_30_reading_fnirs_data.py

Co-authored-by: Robert Luke <[email protected]>

* updated plot_30 tutorial boxy info

* typo

* FIX: SI units and backticks

* FIX: Unit

* FIX: Wording, comma

Co-authored-by: Jonathan Kuziek <[email protected]>
Co-authored-by: Eric Larson <[email protected]>
Co-authored-by: Robert Luke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants