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

Add allen institute vendored code + Neuropil subtraction exploration #21

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
33 changes: 33 additions & 0 deletions derotation/postprocessing/neuropil_subtraction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import vendor.allensdk.brain_observatory.dff as dff_module
from vendor.allensdk.brain_observatory.r_neuropil import NeuropilSubtract


def neuropil_subtraction(f, f_neu) -> tuple:
"""Compute neuropil subtraction and dF/F for a given ROI

Parameters
----------
f : np.ndarray
Fluorescence trace of the ROI
f_neu : np.ndarray
Fluorescence trace of the neuropil

Returns
-------
tuple(np.ndarray, np.ndarray)
dF/F and neuropil signal
"""
neuropil_subtraction = NeuropilSubtract()
neuropil_subtraction.set_F(f, f_neu)
neuropil_subtraction.fit()

r = neuropil_subtraction.r

f_corr = f - r * f_neu

# kernel values to be chossen for 3-photon data
dff = 100 * dff_module.compute_dff_windowed_median(
f_corr, median_kernel_long=1213, median_kernel_short=23
)

return dff, r
34 changes: 34 additions & 0 deletions vendor/allensdk/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Allen Institute Software License - This software license is the 2-clause BSD
license plus a third clause that prohibits redistribution for commercial
purposes without further permission.

Copyright 2017. Allen Institute. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Redistributions for commercial purposes are not permitted without the
Allen Institute's written permission.
For purposes of this license, commercial purposes is the incorporation of the
Allen Institute's software into anything for which you will charge fees or
other compensation. Contact [email protected] for commercial licensing
opportunities.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Empty file added vendor/allensdk/__init__.py
Empty file.
Loading
Loading