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

rc/1.6.0 #1378

Merged
merged 47 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cb22457
ecephys_session notebook update
jsiegle Dec 2, 2019
c9bdf7f
Fix merge conflict
jsiegle Dec 2, 2019
d599f35
Merge remote-tracking branch 'upstream/rc/1.3.0' into add_rf_alias
jsiegle Dec 5, 2019
41bc85d
Add more convenient alias for _get_rf
jsiegle Dec 5, 2019
f3ab86f
Revert nb changes
jsiegle Dec 5, 2019
391459e
version and cache spec
bendichter Feb 10, 2020
8614d74
add version to AIBS_ophys_behavior
bendichter Feb 10, 2020
1598184
[DATALAD RUNCMD] minor typo
yarikoptic Feb 18, 2020
f172f4a
Fixed bug requiring additional IDs for BehaviorDataLimsApi
pickles-bread-and-butter Feb 20, 2020
08808db
Return None instead of empty list if there are no ophys_experiment_ids
pickles-bread-and-butter Feb 20, 2020
8a87938
ecephys_session notebook update
jsiegle Dec 2, 2019
9dd76d3
Add optotagging tutorial
jsiegle Feb 20, 2020
43fa365
Revert ecephys_session changes
jsiegle Feb 20, 2020
c3a83a9
Fix list numbering
jsiegle Feb 20, 2020
e6aadd7
version -> 1.6.0
NileGraddis Feb 22, 2020
7fa1de9
Merge pull request #1374 from AllenInstitute/1354
pickles-bread-and-butter Feb 24, 2020
f5828bf
Merge branch 'master' into rc/1.6.0
NileGraddis Feb 24, 2020
ff1714f
Merge branch 'master' into rc/1.6.0
NileGraddis Feb 26, 2020
ea8af99
GH 771: Remove redundant 'sham_change' column from trials
kschelonka Feb 27, 2020
36b7cec
Merge pull request #1370 from yarikoptic/bf-typo
kschelonka Feb 27, 2020
35aec61
Merge pull request #1375 from jsiegle/opto-tutorial
kschelonka Feb 27, 2020
0bc9c64
Merge branch 'master' into rc/1.6.0
kschelonka Feb 28, 2020
24c0ca2
Fix version merge artifact
kschelonka Feb 28, 2020
4b85163
GH #900: Compute display lag
kschelonka Feb 28, 2020
17bf241
GH #900: Compute display lag
kschelonka Feb 28, 2020
12f52d7
Merge pull request #1358 from ben-dichter-consulting/fix/ecephys_ndx
kschelonka Feb 29, 2020
6abf105
Merge pull request #1400 from AllenInstitute/GH-900/compute-display-lag
kschelonka Mar 2, 2020
0e53425
GH-712: Fix auto-rewarded in rewards results
kschelonka Mar 5, 2020
f4dd74b
Merge pull request #1397 from AllenInstitute/GH-771/update/remove-red…
kschelonka Mar 5, 2020
10b83ee
Merge pull request #1405 from AllenInstitute/GH-712/bugfix/auto-rewar…
kschelonka Mar 5, 2020
e05e2ab
GH-1404: Handle monitor delay errors
kschelonka Mar 6, 2020
50a2f7d
Revert "GH-1404: Handle monitor delay errors"
kschelonka Mar 6, 2020
3f23f0f
GH 1411: Checksum large data in chunks.
kschelonka Mar 10, 2020
26a1c73
Merge branch 'master' into rc/1.6.0
kschelonka Mar 10, 2020
8701e34
Merge pull request #1413 from AllenInstitute/GH-1411/bugfix/checksum-…
kschelonka Mar 11, 2020
69d4edd
Merge pull request #1244 from jsiegle/add_rf_alias
njmei Mar 11, 2020
057b955
Added cache_spec==True keyword to lfp_writer.write call
pickles-bread-and-butter Mar 11, 2020
f7b3b59
Removed help from NWB file attributes
pickles-bread-and-butter Mar 11, 2020
dadee8b
Merge pull request #1427 from AllenInstitute/1426
pickles-bread-and-butter Mar 13, 2020
f50680d
GH 1357: Project caches should not accept arbitrary kwargs
kschelonka Feb 8, 2020
4350828
Remove unnecessary imports and update asynchronous type in BehaviorPr…
kschelonka Mar 13, 2020
5bbb408
Merge pull request #1359 from ben-dichter-consulting/version_ophys_be…
kschelonka Mar 13, 2020
386b3a0
Merge pull request #1428 from AllenInstitute/1420
pickles-bread-and-butter Mar 13, 2020
57b67b2
Merge pull request #1373 from AllenInstitute/GH-1347/cache-kwarg-fix
kschelonka Mar 13, 2020
e006d3e
updating to keyword density from normed for matplotlib.pyplot.hist
djkapner Mar 23, 2020
ca650cc
Merge pull request #1450 from AllenInstitute/update_deprecated_matplo…
djkapner Mar 23, 2020
4f873c4
update what's new and changelog
djkapner Mar 23, 2020
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
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# Change Log
All notable changes to this project will be documented in this file.

## [1.6.0] = 2020-03-23

### Added
- tutorial for optotagging for ecephys notebook
- get\_receptive\_field() method in ecephys receptive field mapping

### Changed
- remove redundant sham\_change column in behavior sessions.trials table
- versions for NWB output for ecephys and ophys behavior.
- monitor delay is now calculated for BehaviorOphysLimsApi rather than defaulting to 0.0351

### Bug Fixes
- Fixed a bug where auto-rewarded trials were not properly attributed in the rewards property of a visual behavior
- return None rather than raise exception if no container id was returned from lims id for given ophys id
- Project caches no longer accept arbitrary keywords
- matplotloib.pyplot.hist parameter normed no longer supported


## [1.5.0] = 2020-02-10

### Added
Expand Down
2 changes: 1 addition & 1 deletion allensdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import logging


__version__ = '1.5.1'
__version__ = '1.6.0'


try:
Expand Down
102 changes: 79 additions & 23 deletions allensdk/brain_observatory/behavior/behavior_project_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import os.path
import csv
from functools import partial
from typing import Type, Callable, Optional, List, Any, Dict
from typing import Type, Optional, List, Any, Dict, Union
from pathlib import Path
import pandas as pd
import time
import logging
Expand All @@ -15,8 +16,7 @@
import BehaviorProjectBase
from allensdk.api.caching_utilities import one_file_call_caching, call_caching
from allensdk.core.exceptions import MissingDataError
from allensdk.core.auth_config import LIMS_DB_CREDENTIAL_MAP
from allensdk.core.authentication import credential_injector, DbCredentials
from allensdk.core.authentication import DbCredentials

BehaviorProjectApi = Type[BehaviorProjectBase]

Expand Down Expand Up @@ -64,11 +64,17 @@ def __init__(
self,
fetch_api: Optional[BehaviorProjectApi] = None,
fetch_tries: int = 2,
**kwargs):
manifest: Optional[Union[str, Path]] = None,
version: Optional[str] = None,
cache: bool = True):
""" Entrypoint for accessing visual behavior data. Supports
access to summaries of session data and provides tools for
downloading detailed session data (such as dff traces).

Likely you will want to use a class constructor, such as `from_lims`,
to initialize a BehaviorProjectCache, rather than calling this
directly.

--- NOTE ---
Because NWB files are not currently supported for this project (as of
11/2019), this cache will not actually save any files of session data
Expand All @@ -87,38 +93,88 @@ def __init__(
Used to pull data from remote sources, after which it is locally
cached. Any object inheriting from BehaviorProjectBase is
suitable. Current options are:
EcephysProjectLimsApi :: Fetches bleeding-edge data from the
BehaviorProjectLimsApi :: Fetches bleeding-edge data from the
Allen Institute"s internal database. Only works if you are
on our internal network.
fetch_tries :
Maximum number of times to attempt a download before giving up and
raising an exception. Note that this is total tries, not retries
**kwargs :
manifest : str or Path
full path at which manifest json will be stored
version : str
version of manifest file. If this mismatches the version
recorded in the file at manifest, an error will be raised.
other kwargs are passed to allensdk.api.cache.Cache
raising an exception. Note that this is total tries, not retries.
Default=2.
manifest : str or Path
full path at which manifest json will be stored. Defaults
to "behavior_project_manifest.json" in the local directory.
version : str
version of manifest file. If this mismatches the version
recorded in the file at manifest, an error will be raised.
Defaults to the manifest version in the class.
cache : bool
Whether to write to the cache. Default=True.
"""
kwargs["manifest"] = kwargs.get("manifest",
"behavior_project_manifest.json")
kwargs["version"] = kwargs.get("version", self.MANIFEST_VERSION)
manifest_ = manifest or "behavior_project_manifest.json"
version_ = version or self.MANIFEST_VERSION

super().__init__(**kwargs)
self.fetch_api = fetch_api or BehaviorProjectLimsApi.default()
super().__init__(manifest=manifest_, version=version_, cache=cache)
self.fetch_api = fetch_api
self.fetch_tries = fetch_tries
self.logger = logging.getLogger(self.__class__.__name__)

@classmethod
def from_lims(cls, lims_credentials: Optional[DbCredentials] = None,
def from_lims(cls, manifest: Optional[Union[str, Path]] = None,
version: Optional[str] = None,
cache: bool = True,
fetch_tries: int = 2,
lims_credentials: Optional[DbCredentials] = None,
mtrain_credentials: Optional[DbCredentials] = None,
app_kwargs: Dict[str, Any] = None, **kwargs):
return cls(fetch_api=BehaviorProjectLimsApi.default(
host: Optional[str] = None,
scheme: Optional[str] = None,
asynchronous: bool = True) -> "BehaviorProjectCache":
"""
Construct a BehaviorProjectCache with a lims api. Use this method
to create a BehaviorProjectCache instance rather than calling
BehaviorProjectCache directly.

Parameters
==========
manifest : str or Path
full path at which manifest json will be stored
version : str
version of manifest file. If this mismatches the version
recorded in the file at manifest, an error will be raised.
cache : bool
Whether to write to the cache
fetch_tries : int
Maximum number of times to attempt a download before giving up and
raising an exception. Note that this is total tries, not retries
lims_credentials : DbCredentials
Optional credentials to access LIMS database.
If not set, will look for credentials in environment variables.
mtrain_credentials: DbCredentials
Optional credentials to access mtrain database.
If not set, will look for credentials in environment variables.
host : str
Web host for the app_engine. Currently unused. This argument is
included for consistency with EcephysProjectCache.from_lims.
scheme : str
URI scheme, such as "http". Currently unused. This argument is
included for consistency with EcephysProjectCache.from_lims.
asynchronous : bool
Whether to fetch from web asynchronously. Currently unused.
Returns
=======
BehaviorProjectCache
BehaviorProjectCache instance with a LIMS fetch API
"""
if host and scheme:
app_kwargs = {"host": host, "scheme": scheme,
"asynchronous": asynchronous}
else:
app_kwargs = None
fetch_api = BehaviorProjectLimsApi.default(
lims_credentials=lims_credentials,
mtrain_credentials=mtrain_credentials,
app_kwargs=app_kwargs),
**kwargs)
app_kwargs=app_kwargs)
return cls(fetch_api=fetch_api, manifest=manifest, version=version,
cache=cache, fetch_tries=fetch_tries)

def get_session_table(
self,
Expand Down
8 changes: 4 additions & 4 deletions allensdk/brain_observatory/behavior/rewards_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@


def get_rewards(data, stimulus_rebase_function):
trial_df = pd.DataFrame(data["items"]["behavior"]['trial_log'])
rewards_dict = {'volume': [], 'timestamps': [], 'autorewarded': []}
trial_df = pd.DataFrame(data["items"]["behavior"]["trial_log"])
rewards_dict = {"volume": [], "timestamps": [], "autorewarded": []}
for idx, trial in trial_df.iterrows():
rewards = trial["rewards"] # as i write this there can only ever be one reward per trial
if rewards:
rewards_dict["volume"].append(rewards[0][0])
rewards_dict["timestamps"].append(stimulus_rebase_function(rewards[0][1]))
rewards_dict["autorewarded"].append('auto_rewarded' in trial['trial_params'])
rewards_dict["autorewarded"].append(trial["trial_params"]["auto_reward"])

df = pd.DataFrame(rewards_dict).set_index('timestamps', drop=True)
df = pd.DataFrame(rewards_dict).set_index("timestamps", drop=True)

return df
1 change: 1 addition & 0 deletions allensdk/brain_observatory/behavior/trials_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def get_trials(data, licks_df, rewards_df, stimulus_presentations_df, rebase):

trials = pd.DataFrame(all_trial_data).set_index('trial')
trials.index = trials.index.rename('trials_id')
del trials["sham_change"]

return trials

Expand Down
16 changes: 11 additions & 5 deletions allensdk/brain_observatory/ecephys/copy_utility/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@
from allensdk.brain_observatory.argschema_utilities import write_or_print_outputs


def hash_file(path, hasher_cls):
with open(path, 'rb') as file_obj:
hasher = hasher_cls()
hasher.update(file_obj.read())
return hasher.digest()
def hash_file(path, hasher_cls, blocks_per_chunk=128):
"""

"""
hasher = hasher_cls()
with open(path, 'rb') as f:
# TODO: Update to new assignment syntax if drop < python 3.8 support
for chunk in iter(
lambda: f.read(hasher.block_size*blocks_per_chunk), b""):
hasher.update(chunk)
return hasher.digest()


def walk_fs_tree(root, fn):
Expand Down
Loading