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

WIP: 0.9 #432

Merged
merged 116 commits into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
f9b651e
Merge branch 'enh-sorted' of https://github.com/yarikoptic/pybids int…
tyarkoni Mar 21, 2019
1bd8ecc
update authors/affils
tyarkoni Mar 27, 2019
4f98a07
WIP: add sqlalchemy models
tyarkoni Mar 27, 2019
a050b95
first partially working solution
tyarkoni Mar 28, 2019
e272021
fix dtype handling in Tag init
tyarkoni Mar 28, 2019
d05b1ba
load or create database on Layout init
tyarkoni Mar 28, 2019
835bd7c
make SQLAlchemy session globally accessible
tyarkoni Mar 28, 2019
0187bfe
add Config SQLAlchemy model
tyarkoni Mar 28, 2019
b8f3a7f
test Config model
tyarkoni Mar 28, 2019
4d9d441
add Scope model
tyarkoni Mar 28, 2019
d55c1f2
fix relationships
tyarkoni Mar 28, 2019
2a18a40
placeholder test for Scope
tyarkoni Mar 28, 2019
c0ceb5e
temporarily replace core classes with SQLAlchemy models
tyarkoni Mar 28, 2019
ee925ae
kill old classes and restructure modules
tyarkoni Mar 29, 2019
5947faa
various fixes
tyarkoni Mar 29, 2019
5b1273a
make sure dtypes are represented as strings before serialization
tyarkoni Mar 29, 2019
c326f47
index metadata
tyarkoni Mar 29, 2019
3f7860c
update get_file to work with DB models
tyarkoni Mar 29, 2019
c560bba
add JSON handling to Tag; fix dtype conversion
tyarkoni Apr 8, 2019
3805e8f
~working reimplementation of get() method
tyarkoni Apr 8, 2019
d57452c
fix model tests
tyarkoni Apr 8, 2019
1e30148
fix failing test and temporarily comment out unimplemented test
tyarkoni Apr 8, 2019
6e9997a
comment out MetadataIndex and make sure session gets passed to Config…
tyarkoni Apr 9, 2019
69953d6
add extension entity
tyarkoni Apr 9, 2019
6e18c55
fixes to indexing
tyarkoni Apr 9, 2019
1135d5c
update get_metadata to query the DB
tyarkoni Apr 9, 2019
c91c0bf
track whether BIDSFiles are directories
tyarkoni Apr 9, 2019
259c27a
return existing Config from .load() if one exists
tyarkoni Apr 9, 2019
38a4cbd
mostly working purely DB-based implementation
tyarkoni Apr 9, 2019
0df3f8d
improved efficiency in to_df() and added metadata flag
tyarkoni Apr 9, 2019
4c22cc1
remove Scope model in favor of multiple-DB solution
tyarkoni Apr 9, 2019
ce03f4b
add in_scope method to determine if layout is in passed scope
tyarkoni Apr 9, 2019
e79c5d5
add test of _in_scope
tyarkoni Apr 9, 2019
97fc7fe
fix _get_layouts_in_scope()
tyarkoni Apr 10, 2019
b8c12a1
reorder attributes and populate .entities from database
tyarkoni Apr 10, 2019
263a08f
add getters for files and entities
tyarkoni Apr 10, 2019
d8f8629
.entities and .files should have maximal scope by default
tyarkoni Apr 10, 2019
b5d6183
collect results from all in-scope layouts
tyarkoni Apr 10, 2019
a99be43
extensions --> extension
tyarkoni Apr 10, 2019
836880d
allow leading periods in extension filter for backwards compatibility
tyarkoni Apr 10, 2019
a38169a
fix get_metadata--return values, not file paths
tyarkoni Apr 10, 2019
d5a707f
fix metadata indexing
tyarkoni Apr 10, 2019
80af17b
disallow list values when regex search is enabled
tyarkoni Apr 10, 2019
eb0511d
add regexp function and handle list values
tyarkoni Apr 10, 2019
11bcd71
fix tests
tyarkoni Apr 10, 2019
df0ef7b
fix get_file query
tyarkoni Apr 10, 2019
bd59381
don't test copying until we figure out what to do about it
tyarkoni Apr 10, 2019
a682ec5
BIDSFiles no longer have access to layout, so update __repr__
tyarkoni Apr 10, 2019
3268893
replace .metadata property with get_metadata(), and fix DB call
tyarkoni Apr 10, 2019
183add1
fix get_nearest by making 'extension' default for ignore_strict_entities
tyarkoni Apr 10, 2019
db35c2c
eager load Tag and Entity associations in get() otherwise we have ses…
tyarkoni Apr 10, 2019
d9091b6
add warning in case derivatives were requested but none were found
tyarkoni Apr 10, 2019
80a48e6
fix force indexing--make sure arg is passed to indexing
tyarkoni Apr 10, 2019
c3e3af5
fixes to test_core, even though it's going to disappear soon
tyarkoni Apr 10, 2019
4510e93
drop metadata index tests now that there's no metadata index
tyarkoni Apr 10, 2019
7b4f2cc
fix path writing tests
tyarkoni Apr 10, 2019
8446a4d
fix get_metadata to accept scope arg
tyarkoni Apr 10, 2019
1d0dbe5
extensions --> extension
tyarkoni Apr 10, 2019
2225311
add get_data skeleton
tyarkoni Apr 10, 2019
559d396
kill off 'extensions' argument for good
tyarkoni Apr 10, 2019
6f19781
move layout fixtures into conftest.py
tyarkoni Apr 10, 2019
6b1faee
add get_df() method to BIDSFile
tyarkoni Apr 11, 2019
7ce8df1
defines association relation; see #431
tyarkoni Apr 11, 2019
44c5b7f
enable filtering by association type
tyarkoni Apr 11, 2019
2b5dfec
privatize associations
tyarkoni Apr 11, 2019
476485c
refactor indexing--separate metadata indexing for readability
tyarkoni Apr 11, 2019
1e306d7
bulk commit for speed
tyarkoni Apr 11, 2019
096ba0d
create FileAssociations for metadata
tyarkoni Apr 11, 2019
e2ecbf2
create FileAssociation records for inheritance
tyarkoni Apr 11, 2019
6dd1f8b
fix layout test and various minor tweaks
tyarkoni Apr 12, 2019
fc9c5ed
fix relative path layouts: always index using absolute paths
tyarkoni Apr 12, 2019
057a9a0
add option to include ancestor BIDSFiles in association list
tyarkoni Apr 12, 2019
726364a
allow either 'filename' or 'file' as get() return_type arg
tyarkoni Apr 12, 2019
87483c4
add file associations between files, and associated test
tyarkoni Apr 12, 2019
e8a7e97
add BIDSLayout arg to control metadata indexing
tyarkoni Apr 12, 2019
a1d410d
fix i/o tests
tyarkoni Apr 12, 2019
594655a
better handling of duplicate entity columns
tyarkoni Apr 12, 2019
b7cede5
fix failing tests to work with changes
tyarkoni Apr 12, 2019
7d567de
Merge branch 'master' into sqlalchemy
tyarkoni Apr 12, 2019
cf21aee
just when I thought it was gone, they pull it back in
tyarkoni Apr 12, 2019
e03f213
fix breaking test
tyarkoni Apr 12, 2019
d3d27df
fix tests
tyarkoni Apr 18, 2019
dd95b08
add arguments controlling location/reindexing of SQLite database
tyarkoni Apr 19, 2019
9141555
conditionalize reindexing
tyarkoni Apr 19, 2019
a0c321f
add custom REGEXP function on begin event
tyarkoni Apr 19, 2019
5cca84e
make sure all test fixtures re-index datasets
tyarkoni Apr 19, 2019
85f9767
revert to using in-memory DB by default
tyarkoni Apr 19, 2019
5f96e3b
add ability to save in-memory DB to file via .save()
tyarkoni Apr 19, 2019
e9f3647
Python 2 doesn't like em-dashes
tyarkoni Apr 19, 2019
6cf7e54
avoid Python 3 argument unpacking
tyarkoni Apr 19, 2019
e7b2816
fixes BIDSVariable deepcopy error by ensuring we have no connection t…
tyarkoni Apr 20, 2019
604d560
add deprecation warning for 'extensions' arg to get and improve docst…
tyarkoni Apr 20, 2019
30767c8
update models.py docstrings
tyarkoni Apr 20, 2019
1931bb2
reorganize indexing/validation code for better readability/modularity
tyarkoni Apr 21, 2019
f0925b3
fix inclusion/exclusion handling and add tests
tyarkoni Apr 21, 2019
7d87fa2
add missing test file
tyarkoni Apr 21, 2019
85cb8d3
refactor BIDSFile into hierarchy of classes
tyarkoni Apr 22, 2019
1624a91
ignore external and setup-related files
tyarkoni Apr 22, 2019
60af65b
fix BIDSDataFile test and clean up
tyarkoni Apr 22, 2019
2bcdd85
CHANGELOG updates
tyarkoni Apr 30, 2019
e197d62
Merge branch 'master' into sqlalchemy
tyarkoni Apr 30, 2019
7072482
update CHANGELOG
tyarkoni Apr 30, 2019
eeb80a7
ugly-ass fix for Python 3.5 test failure, and cleanup
tyarkoni Apr 30, 2019
2af4650
include FileAssociation kind in uniqueness constraint
tyarkoni May 1, 2019
cc462c0
don't commit redundant FileAssociations
tyarkoni May 1, 2019
0ac80d0
fix wrong order of args
tyarkoni May 1, 2019
5e8308e
add get_entities method to BIDSFile and reorder attributes
tyarkoni May 7, 2019
2b68130
rename is_metadata argument to just metadata
tyarkoni May 7, 2019
a3b07d1
reorganize BIDSFile tests
tyarkoni May 7, 2019
7f689fe
add BIDSFile.get_entities() method and tests
tyarkoni May 7, 2019
52c6a7f
updated and expanded tutorial
tyarkoni May 7, 2019
29b1014
no need for JSON column when a String will do; closes #437
tyarkoni May 10, 2019
85eee6e
lose the JSON import
tyarkoni May 10, 2019
b518712
update CHANGELOG in prep for release
tyarkoni May 10, 2019
528f253
Merge branch 'master' into sqlalchemy
tyarkoni May 10, 2019
b93b272
Merge branch 'master' into sqlalchemy
tyarkoni May 10, 2019
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
7 changes: 5 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
branch = True
source = bids/*
include = bids/*
omit = */setup.py

omit =
*/setup.py
*/external/*
*/due.py
*/*version.py
[report]
include = bids/*
62 changes: 62 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
# Changelog

## Version 0.9.0 (May 10, 2019)
Version 0.9 replaces the native Python backend with a SQLite database managed
via SQLAlchemy. The layout module has been refactored (again), but API changes
are minimal. This release also adds many new features and closes a number of
open issues.

API CHANGES/DEPRECATIONS:
* The `extensions` argument has now been banished forever; instead, use
`extension`, which is now defined as a first-class entity. The former will
continue to work until at least the 0.11 release (closes #404).
* Relatedly, values for `extension` should no longer include a leading `.`,
though this should also continue to work for the time being.
* The `BIDSLayout` init argument `index_associated` has been removed as the
various other filtering/indexing options mean there is longer a good reason for
users to manipulate this.
* `bids.layout.MetadataIndex` no longer exists. It's unlikely that anyone will
notice this.
* `BIDSLayout.get_metadata()` no longer takes additional entities as optional
keyword arguments (they weren't necessary for anything).
* Direct access to most `BIDSFile` properties is discouraged, and in one case
is broken in 0.9 (for `.metadata`, which was unavoidable, because it's reserved
by SQLAlchemy). Instead, users should use getters (`get_metadata`, `get_image`,
`get_df`, etc.) whenever possible.

NEW FUNCTIONALITY:
* All file and metadata indexing and querying is now supported by a
relational (SQLite) database (see #422). While this has few API implications,
the efficiency of many operations is improved, and complex user-generated
queries can now be performed via the SQLAlchemy `.session` stored in each
`BIDSLayout`.
* Adds `.save()` method to the `BIDSLayout` that saves the current SQLite DB
to the specified location. Conversely, passing a filename as `database_file` at
init will use the specified store instead of re-indexing all files. This
eliminates the need for a pickling strategy (#435).
* Related to the above, the `BIDSLayout` init adds a `reset_database` argument
that forces reindexing even if a `database_file` is specified.
* The `BIDSLayout` has a new `index_metadata` flag that controls whether or
not the contents of JSON metadata files are indexed.
* Added `metadata` flag to `BIDSLayout.to_df()` that controls whether or not
metadata columns are included in the returned pandas `DataFrame` (#232).
* Added `get_entities()` method to `BIDSLayout` that allows retrieval of all
`Entity` instances available within a specified scope (#346).
* Adds `drop_invalid_filters` argument to `BIDSLayout.get()`, enabling users to
(optionally) ensure that invalid filters don't clobber all search results
(#402).
* `BIDSFile` instances now have a `get_associations()` method that returns
associated files (see #431).
* The `BIDSFile` class has been split into a hierarchy, with `BIDSImageFile`
and `BIDSDataFile` subclasses. The former adds a `get_image()` method (returns
a NiBabel image); the latter adds a `get_df()` method (returns a pandas DF).
All `BIDSFile` instances now also have a `get_entities()` method.

BUG FIXES AND OTHER MINOR CHANGES:
* Metadata key/value pairs and file entities are now treated identically,
eliminating a source of ambiguity in search (see #398).
* Metadata no longer bleeds between raw and derivatives directories unless
explicitly specified (see #383).
* `BIDSLayout.get_collections()` no longer drops user-added columns (#273).
* Various minor fixes/improvements/changes to tests.
* The tutorial Jupyter notebook has been fixed and updated to reflect the
latest changes.

## Version 0.8.0 (February 15, 2019)
Version 0.8 refactors much of the layout module. It drops the grabbit
dependency, overhauls the file indexing process, and features a number of other
Expand Down
6 changes: 3 additions & 3 deletions bids/analysis/tests/test_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ def test_get_design_matrix_arguments(analysis):
sampling_rate='highest')
result = analysis['run'].get_design_matrix(**kwargs)[0]
assert result.sparse is None
assert result.dense.shape == (4800, 6)
assert result.dense.shape == (4800, 9)

kwargs = dict(run=1, subject='01', mode='dense', force=True,
sampling_rate='TR')
result = analysis['run'].get_design_matrix(**kwargs)[0]
assert result.sparse is None
assert result.dense.shape == (240, 6)
assert result.dense.shape == (240, 9)

kwargs = dict(run=1, subject='01', mode='dense', force=True,
sampling_rate=0.5)
result = analysis['run'].get_design_matrix(**kwargs)[0]
assert result.sparse is None
assert result.dense.shape == (240, 6)
assert result.dense.shape == (240, 9)

# format='long' should be ignored for dense output
kwargs = dict(run=1, subject='01', mode='dense', force=True,
Expand Down
2 changes: 1 addition & 1 deletion bids/layout/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .layout import BIDSLayout, add_config_paths, parse_file_entities
from .core import BIDSFile
from .models import BIDSFile
# Backwards compatibility
from bids_validator import BIDSValidator

Expand Down
7 changes: 5 additions & 2 deletions bids/layout/config/bids.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"name": "session",
"pattern": "[_/\\\\]+ses-([a-zA-Z0-9]+)",
"mandatory": false,
"directory": "{subject}{session}",
"missing_value": "ses-1"
"directory": "{subject}{session}"
},
{
"name": "task",
Expand Down Expand Up @@ -69,6 +68,10 @@
{
"name": "datatype",
"pattern": "[/\\\\]+(func|anat|fmap|dwi|meg)[/\\\\]+s"
},
{
"name": "extension",
"pattern": "[._]*[a-zA-Z0-9]*?\\.([^/\\\\]+)$"
}
],

Expand Down
Loading