[WIP] Replacing paradim
with events
or experimental paradigm
as per BIDS
#253
Conversation
- Added _make_localizer_first_level_paradigm_file_bids_compliant() to overwrite the downloaded events file with BIDS compliant version. - Added unit test for above function in nistats/tests/ - nistats/datasets.py imports reordered in compliance with PEP8.
- Renamed _make_localizer_first_level_paradigm_file_bids_compliant() to _make_bids_compliant_localizer_first_level_paradigm_file()
…liant.py - Renamed test_make_localizer_first_level_paradigm_file_bids_compliant.py to test_make_bids_compliant_localizer_first_level_paradigm_file.py
* master: utils._verify_events_file_uses_tab_separators() no longer returns any value Moved test file from nistats/tests/unit_tests/ to nistats/tests/ Corrected unit test filename to test_verify_events_file_uses_tab_separators Added unit tests for nistats._utils._verify_events_file_uses_tab_separators() Modified comments _verify_events_file_uses_tab_separators() returns a List[List[events, error]] Improved comments Renamed function parameter _not_test to _raise_delimiter_errors_only Renamed + Only first row is used to determine BIDS compliance of events files Added replacement function to raise error if events files use invalid separators Starting point for py3 to py2/3 conversion; Some reformatting Abandoned use of pathlib to maintain compatibility with older python versions Added function to raise error if events file doesn't use tabs or commas Removed unnecessary wrapper functions to read paradigm from tsv,csv files Removed unnecessary wrapper functions to read paradigm from tsv,csv files Added wrapper function to read experimental paradigm from tsv files
…parators() - Pre-mod BIDS compliance check is done by utils._verify_events_file_uses_tab_separators() TravisCI failure, possibly due to previously used function. - Removed datasets._check_bids_compliance_localizer_first_level_paradigm_file()
…ts file - Added datasets._make_spm_auditory_events_file() - Renamed _glob_spm_auditory_data() to _prepare_downloaded_spm_auditory_data() and refactored it out. - Refactored datasets.fetch_spm_auditory() into 3 functions: _download_spm_auditory_data(), _prepare_downloaded_spm_auditory_data(), _make_spm_auditory_events_file() .
- Added nistats.datasets._make_path_events_file_spm_auditory().
…st_datasets Changed the tutorial text in example plot_single_subject_run.py - Removed mention of events.csv . - Removed mention of events == paradigms.
- datasets._get_func_data_spm_multimodal() - datasets._get_session_trials_spm_multimodal() - datasets._get_anatomical_data_spm_multimodal() - datasets._glob_spm_multimodal_fmri_data() - datasets._download_data_spm_multimodal() - Added datasets._make_events_file_spm_multimodal_fmri() [INCOMPLETE]
…s in tests - Added _make_events_filepath_spm_multimodal_fmri(). - Events files are not egnerated during nosetests, and a warning is presented.
* master: doc fixes changed default oversampling to 50 exposed oversampling parameter
…faces.py - datasets.fetch_spm_multimodal_fmri() generates sessions from 1, not 0.
- Added nistats.utils._read_events_table()
…ppropriate - Minor documentation tweaks. - Replacing events access as key instead of attribute: data['events'] replaces data.events
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.
Thx, this is a great contribution, with only a few minor details.
However, several things are already included in open PRs. Will have to wait a bit before merging.
paradigm : pandas DataFrame | ||
Describes a functional paradigm. | ||
events : pandas DataFrame | ||
Describes the events in a functional experimental paradigm. |
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.
Can remove "functional"
# We can read such a table from a spreadsheet file created with OpenOffice Calcor Office Excel, and saved under the *comma separated values* format (``.csv``). | ||
# timing of the auditory stimulation and rest periods (events). | ||
# This is typically provided in an events.tsv file. The path of this file is | ||
# provided in the dataset. | ||
import pandas as pd |
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.
Amigo, we're going to have a big clash with PR #231. This one will have to go after.
A paradigm is considered as valid whenever it has an 'onset' key, if | ||
this key is missing an exception will be thrown. For the others keys | ||
only a simple warning will be displayed. A particular attention should | ||
The events data is considered valid whenever it has an 'onset' key. |
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.
is -> are
Description of the experimental paradigm. The DataFrame instance might | ||
have those keys: | ||
events : DataFrame instance, optional | ||
Events data that describes the experimental paradigm. The DataFrame instance might |
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.
describe
if 'modulation' in paradigm.keys(): | ||
warnings.warn("'modulation' key not found in the given paradigm.") | ||
modulation = np.array(paradigm['modulation']).astype(np.float) | ||
if 'trial_type' in events.keys(): |
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.
@@ -23,15 +23,39 @@ def _check_list_length_match(list_1, list_2, var_name_1, var_name_2): | |||
% (str(var_name_1), len(list_1), str(var_name_2), len(list_2))) | |||
|
|||
|
|||
def _read_events_table(table): |
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.
Isn't this featue used in many locations of the codebase ?
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.
Didn't understand your suggestion.
I created this today because we now have two types of table-like files:
- csv with index_col=0. (Many tests are also using such data)
- tsv with index_col=False (BIDS compliant events files)
Are you saying I should unprotect it (remove the undescore) and make it a regular, reusable function?
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.
unprotect the function -> Only if it indeed used somewhere else.
(I was just wondering)
OK, I have started merging branches to master, which elicits these conflicts :-( |
Yeah, no worries, we'll resolve this one once you are done with those merges. |
There are lots of potential merge conflicts. I will resume work on this one on Sunday, until then most of the other PRs will likely be merged |
The PR is transferred to #257 |
Must be merged only AFTER merging #238
For issue #216