Skip to content
Open
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
20 changes: 20 additions & 0 deletions corticalmapping.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Metadata-Version: 2.1
Name: corticalmapping
Version: 2.0.0
Summary: cortical mapping tools
Home-page: http://stash.corp.alleninstitute.org/users/junz/repos/corticalmapping/
Author: Jun Zhuang
Author-email: junz@alleninstitute.org
License: UNKNOWN
Description: corticalmapping

by Jun Zhuang @ 2014

contains basic visual stimulation, imaging analysis, plotting, cell visual response properties analysis functionalities.
also contains a relatively mature code base of retinotopic mapping (visual stimulation and analysis)
Platform: any
Classifier: Programming Language :: Python
Classifier: Development Status :: 4 - Beta
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Provides-Extra: testing
38 changes: 38 additions & 0 deletions corticalmapping.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
README.md
setup.py
corticalmapping/CaimanTools.py
corticalmapping/CamstimTools.py
corticalmapping/DatabaseTools.py
corticalmapping/HighLevel.py
corticalmapping/MotionCorrection.py
corticalmapping/NwbTools.py
corticalmapping/ResponseAnalysis.py
corticalmapping/RetinotopicMapping.py
corticalmapping/SingleCellAnalysis.py
corticalmapping/VasculatureMapMatching.py
corticalmapping/VisualStim.py
corticalmapping/__init__.py
corticalmapping/setup.py
corticalmapping.egg-info/PKG-INFO
corticalmapping.egg-info/SOURCES.txt
corticalmapping.egg-info/dependency_links.txt
corticalmapping.egg-info/requires.txt
corticalmapping.egg-info/top_level.txt
corticalmapping/core/DataAnalysis.py
corticalmapping/core/FileTools.py
corticalmapping/core/ImageAnalysis.py
corticalmapping/core/PlottingTools.py
corticalmapping/core/TimingAnalysis.py
corticalmapping/core/__init__.py
corticalmapping/core/tifffile.py
corticalmapping/ephys/KilosortWrapper.py
corticalmapping/ephys/OpenEphysWrapper.py
corticalmapping/ephys/__init__.py
corticalmapping/ipython_lizard/__init__.py
corticalmapping/ipython_lizard/export_notebook_functions.py
corticalmapping/ipython_lizard/html_widgets.py
corticalmapping/ipython_lizard/ipython_filedialog.py
corticalmapping/ipython_lizard/patchplot_ipywidgets.py
corticalmapping/ipython_lizard/wrapped_retinotopic_mapping.py
corticalmapping/ipython_lizard/utils/__init__.py
corticalmapping/ipython_lizard/utils/progress_bar.py
1 change: 1 addition & 0 deletions corticalmapping.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 8 additions & 0 deletions corticalmapping.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
numpy
scipy
PyDAQmx
scikit-image
tifffile

[testing]
pytest
1 change: 1 addition & 0 deletions corticalmapping.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
corticalmapping
58 changes: 58 additions & 0 deletions corticalmapping/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

#*.iml
*.pyc


## Directory-based project format:
.idea/
.cache/


# if you remove the above rule, at least ignore the following:

# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries

# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml

# Gradle:
# .idea/gradle.xml
# .idea/libraries

# Mongo Explorer plugin:
# .idea/mongoSettings.xml

## File-based project format:
*.ipr
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties


/corticalmapping/ipython_lizard/res/test_pkls
.ipynb_checkpoints

108 changes: 9 additions & 99 deletions corticalmapping/DatabaseTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1717,80 +1717,6 @@ def get_axon_dgcrm_from_clu_f(clu_f, plane_n, axon_n, trace_type):
return dgcrm


def get_axon_morphology(clu_f, nwb_f, plane_n, axon_n):

axon_morph = {}

mc_grp = nwb_f['processing/motion_correction/MotionCorrection/{}/corrected'.format(plane_n)]
pixel_size = mc_grp['pixel_size'].value
# print(pixel_size)
pixel_size_mean = np.mean(pixel_size)

bout_ns = clu_f['axons/{}'.format(axon_n)].value
# print(bout_ns)
bout_num = len(bout_ns)
axon_morph['bouton_num'] = bout_num

if bout_num == 1:
axon_roi = get_roi(nwb_f=nwb_f, plane_n=plane_n, roi_n=bout_ns[0])
else:
axon_roi = get_axon_roi_from_clu_f(clu_f=clu_f, axon_n=axon_n)
axon_roi = ia.WeightedROI(axon_roi.get_weighted_mask(), pixelSize=pixel_size,
pixelSizeUnit=mc_grp['pixel_size_unit'].value)

# plt.imshow(axon_roi.get_binary_mask(), interpolation='nearest')
# plt.show()

axon_morph['axon_row_range'] = (np.max(axon_roi.pixels[0]) -
np.min(axon_roi.pixels[0])) * pixel_size[0] * 1e6
axon_morph['axon_col_range'] = (np.max(axon_roi.pixels[1]) -
np.min(axon_roi.pixels[1])) * pixel_size[1] * 1e6

axon_morph['axon_area'] = axon_roi.get_pixel_area() * 1e12

axon_qhull = spatial.ConvexHull(np.array(axon_roi.pixels).transpose())
# print(axon_qhull.volume)
axon_morph['axon_qhull_area'] = axon_qhull.volume * axon_roi.pixelSizeX * axon_roi.pixelSizeY * 1e12

bout_rois = []
for bout_n in bout_ns:
bout_rois.append(get_roi(nwb_f=nwb_f, plane_n=plane_n, roi_n=bout_n))

bout_areas = [r.get_pixel_area() for r in bout_rois]
bout_area_mean = np.mean(bout_areas)
axon_morph['bouton_area_mean'] = bout_area_mean * 1e12

if bout_num == 1:
bout_area_std = np.nan
else:
bout_area_std = np.std(bout_areas)
axon_morph['bouton_area_std'] = bout_area_std * 1e12

bout_coords = np.array([r.get_center() for r in bout_rois]) # [[y0, x0], [y1, x1], ... , [yn, xn]]
if bout_num == 1:
axon_morph['bouton_row_std'] = np.nan
axon_morph['bouton_col_std'] = np.nan
axon_morph['bouton_dis_mean'] = np.nan
axon_morph['bouton_dis_std'] = np.nan
axon_morph['bouton_dis_median'] = np.nan
axon_morph['bouton_dis_max'] = np.nan
else:
axon_morph['bouton_row_std'] = np.std(bout_coords[:, 0]) * pixel_size_mean * 1e6
axon_morph['bouton_col_std'] = np.std(bout_coords[:, 1]) * pixel_size_mean * 1e6

bout_dis = spatial.distance.pdist(bout_coords) * pixel_size_mean
axon_morph['bouton_dis_mean'] = np.mean(bout_dis) * 1e6
axon_morph['bouton_dis_median'] = np.median(bout_dis) * 1e6
axon_morph['bouton_dis_max'] = np.max(bout_dis) * 1e6

if bout_num == 2:
axon_morph['bouton_dis_std'] = np.nan
else:
axon_morph['bouton_dis_std'] = np.std(bout_dis) * 1e6

return axon_morph


def get_everything_from_axon(nwb_f, clu_f, plane_n, axon_n, params=ANALYSIS_PARAMS, verbose=False):
"""

Expand Down Expand Up @@ -3819,28 +3745,14 @@ def get_sta(arr, arr_ts, trigger_ts, frame_start, frame_end):
if __name__ == '__main__':

# ===================================================================================================
nwb_f = h5py.File(r"G:\bulk_LGN_database\nwbs\190221_M426525_110_repacked.nwb", 'r')
clu_f = h5py.File(r"G:\bulk_LGN_database\intermediate_results\bouton_clustering"
r"\AllStimuli_DistanceThr_1.30\190221_M426525_plane0_axon_grouping.hdf5", 'r')
plane_n = 'plane0'
axon_n = 'axon_0007'
axon_morph = get_axon_morphology(clu_f=clu_f, nwb_f=nwb_f, plane_n=plane_n, axon_n=axon_n)

keys = axon_morph.keys()
keys.sort()
for key in keys:
print('{}: {}'.format(key, axon_morph[key]))
# ===================================================================================================

# ===================================================================================================
# nwb_f = h5py.File(r"G:\bulk_LGN_database\nwbs\190404_M439939_110_repacked.nwb")
# uc_inds, _ = get_UC_ts_mask(nwb_f=nwb_f, plane_n='plane0')
# plt.plot(uc_inds)
# plt.show()
#
# dgc_spont_inds, _ = get_DGC_spont_ts_mask(nwb_f=nwb_f, plane_n='plane0')
# plt.plot(dgc_spont_inds)
# plt.show()
nwb_f = h5py.File(r"G:\bulk_LGN_database\nwbs\190404_M439939_110_repacked.nwb")
uc_inds, _ = get_UC_ts_mask(nwb_f=nwb_f, plane_n='plane0')
plt.plot(uc_inds)
plt.show()

dgc_spont_inds, _ = get_DGC_spont_ts_mask(nwb_f=nwb_f, plane_n='plane0')
plt.plot(dgc_spont_inds)
plt.show()
# ===================================================================================================

# ===================================================================================================
Expand Down Expand Up @@ -3894,6 +3806,4 @@ def get_sta(arr, arr_ts, trigger_ts, frame_start, frame_end):
# plot_roi_retinotopy(coords_roi=coords_roi, coords_rf=coords_rf, ax_alt=ax_alt, ax_azi=ax_azi,
# cmap='viridis', canvas_shape=(512, 512), edgecolors='#000000', linewidths=0.5)
# plt.show()
# ===================================================================================================

print('for debug ...')
# ===================================================================================================
Loading