Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
5cff5e5
got rid of database permissions and enabled new virus scheme
fabiansinz May 16, 2016
d151cb6
remove visual-stimuli
fabiansinz May 19, 2016
16d7de9
Change plots.m under +opt'
May 23, 2016
aea873f
Change plots.m in opt. In plots, need to verify keyTitle.
May 24, 2016
7cde4bb
Merge pull request #17 from fabiansinz/master
dimitri-yatsenko May 27, 2016
e975c33
Added movieclip table
olakiril May 31, 2016
e6968ce
Merge pull request #19 from olakiril/master
dimitri-yatsenko May 31, 2016
23c38cf
Merge remote-tracking branch 'refs/remotes/atlab/master'
olakiril May 31, 2016
2cf5530
New table contains specific movie information & clips are computed wi…
olakiril Jun 1, 2016
d4ed687
Merge pull request #20 from olakiril/master
dimitri-yatsenko Jun 1, 2016
cf2a641
add spawn_missing_classes to python modules
fabiansinz Jun 14, 2016
500fff5
Merge branch 'master' of https://github.com/fabiansinz/commons
fabiansinz Jun 14, 2016
9d09459
psy.MovieParams plot function for Object trajectories
olakiril Jun 15, 2016
b693f26
add spawn_missing_classes
fabiansinz Jun 15, 2016
443372c
Merge pull request #21 from olakiril/master
dimitri-yatsenko Jun 20, 2016
bf08458
Pull from upstream master to get Virus schema
Jun 22, 2016
1a6e8a3
new injection table
fabiansinz Jun 24, 2016
ff8822c
new injection schema
fabiansinz Jun 24, 2016
cc8240b
Merge pull request #22 from fabiansinz/master
dimitri-yatsenko Jun 27, 2016
58d283e
mouse database updates:
cathryn1 Jun 27, 2016
6ff5125
Merge branch 'master' of https://github.com/atlab/commons
cathryn1 Jun 27, 2016
5eb56b7
unsaved changes made to lab directory
cathryn1 Jun 27, 2016
9f16713
Merge branch 'master' of https://github.com/atlab/commons
cathryn1 Jun 27, 2016
6d24363
Minor changes to mouse database - CD1 line as obligatory wild type l…
cathryn1 Jun 29, 2016
573db4b
same as previous commit, forgot to update in other places
cathryn1 Jun 29, 2016
94ca5bd
comment out keyTitle
Jun 30, 2016
871935a
removed TIFFStack usage from Reader5
dimitri-yatsenko Jul 4, 2016
61957ef
hacked Reader5 -- requires further work
dimitri-yatsenko Jul 4, 2016
9228453
fixed bug in raster correction
dimitri-yatsenko Jul 6, 2016
b1aae7f
bugfix in raster correction
dimitri-yatsenko Jul 6, 2016
b5658a7
Merge pull request #23 from dimitri-yatsenko/master
fabiansinz Jul 7, 2016
b6364d2
Install setup.py
Jul 26, 2016
a055e41
Merge branch 'master' of https://github.com/atlab/commons
Jul 26, 2016
4112646
fixed bug in scanimage.Reader5 that produced zeroed frames in the end…
dimitri-yatsenko Jul 27, 2016
2e2cadf
Merge branch 'master' of https://github.com/atlab/commons
dimitri-yatsenko Jul 27, 2016
4aa6235
Merge pull request #24 from dimitri-yatsenko/master
fabiansinz Jul 27, 2016
c79954a
cleanup
dimitri-yatsenko Jul 27, 2016
f3ea7da
Merge branch 'master' of https://github.com/atlab/commons
dimitri-yatsenko Jul 27, 2016
9e29c80
Reader5 now handles interrupted scans.
dimitri-yatsenko Jul 29, 2016
5490c6b
Merge pull request #25 from dimitri-yatsenko/master
fabiansinz Jul 29, 2016
273032d
update injections
fabiansinz Aug 6, 2016
adda83d
Merge branch 'master' of https://github.com/atlab/commons
fabiansinz Aug 8, 2016
e9359bf
new elements in injection table
fabiansinz Aug 8, 2016
29df1c1
Merge pull request #26 from fabiansinz/master
dimitri-yatsenko Aug 8, 2016
7ccd9c2
Reader5 updated to support scanimage 5.2 files
olakiril Aug 18, 2016
776e68c
Merge pull request #27 from olakiril/master
jakereimer Aug 18, 2016
72688fe
Reader5 updated to support scanimage 5.2 files
olakiril Aug 18, 2016
6f77b8a
Reader5 updated to support scanimage 5.2 files
olakiril Aug 18, 2016
47fb288
Merge pull request #28 from olakiril/master
jakereimer Aug 18, 2016
dabbeff
Fix bug with handling of homozygous parents
Aug 24, 2016
3b81177
Merge remote-tracking branch 'refs/remotes/atlab/master'
olakiril Aug 27, 2016
d7b9c35
Updated Reader5 to read correctly the number of fastz slices
olakiril Aug 30, 2016
af9936b
Merge pull request #30 from olakiril/master
dimitri-yatsenko Aug 30, 2016
f999a0c
Bugfix Reader5
jakereimer Aug 30, 2016
0400fbc
Merge pull request #31 from jakereimer/master
olakiril Aug 30, 2016
611a9ab
Merge pull request #29 from eywalker/master
dimitri-yatsenko Aug 30, 2016
87d837f
Added brightness adjustment to manual segmentation
jakereimer Sep 9, 2016
5e9c282
deleted .asv file
jakereimer Sep 9, 2016
72f20b4
removed asv file again
jakereimer Sep 9, 2016
9f3a501
Merge pull request #32 from jakereimer/master
dimitri-yatsenko Sep 9, 2016
00ba88a
Merge remote-tracking branch 'refs/remotes/atlab/master'
olakiril Oct 25, 2016
1224f47
Error messages in plusCallback would trigger for new WT line, Crl-CD1…
Nov 1, 2016
c3e4400
Error messages in plusFounderCallback would trigger for new WT line, …
paulgfahey Nov 1, 2016
bea8d85
Update to datajoint caused error in comparing relations.
paulgfahey Nov 1, 2016
96252de
Merge pull request #33 from paulgfahey/master
jakereimer Nov 1, 2016
5403d11
Get frame number from header info
olakiril Nov 7, 2016
f84d3dc
Merge pull request #34 from olakiril/master
fabiansinz Nov 7, 2016
acd4c67
Merge remote-tracking branch 'refs/remotes/atlab/master'
olakiril Nov 7, 2016
10627b6
Moved Paths to commons
olakiril Nov 18, 2016
d76c42d
Merge pull request #35 from olakiril/master
jakereimer Nov 18, 2016
abc8d91
Merge branch 'master' of https://github.com/atlab/commons into update
Nov 18, 2016
411335d
Add getlocalPath in python
Dec 8, 2016
5d08253
Revert plot.m
Dec 8, 2016
37545c1
Add .egginfo in gitignore
Dec 8, 2016
36b062d
Add .egg-info in gitignore
Dec 8, 2016
dcacf50
Remove egg-info from repository
Dec 8, 2016
e4ecc21
Remove edd-info
Dec 9, 2016
c625198
ChangegetLocalPath into get_local_path
Dec 9, 2016
165897f
Merge pull request #36 from jiakunf/update
eywalker Dec 9, 2016
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.DS_Store
.idea
*__pycache__*
*.edd-info*
*.egg-info*
*.asv
Binary file removed RFMapRaw_Keys.mat
Binary file not shown.
29 changes: 15 additions & 14 deletions lib/+ne7/+ip/correctRaster.m
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
function img = correctRaster(img, rasterPhase, fillFraction)
% raster correction for resonant scanners.
% raster correction for resonant scanners.
% rasterPhase is the phase different between left-right and right-left scan
% lines.
% lines.
%
% img size [x y nSlices nFrames]. 2D, 3D, 4D images also work
% img size [x y nChannel nSlices nFrames]. 2D, 3D, 4D, 5D images also work


sz = [size(img,1) size(img,2) size(img,3) size(img,4)];
ix = (-sz(2)/2+0.5:sz(2)/2-0.5)/(sz(2)/2);
assert(ndims(img)<=5)
ix = (-size(img, 2)/2+0.5:size(img, 2)/2-0.5)/(size(img, 2)/2);
tx = asin(ix*fillFraction); % convert index to time
for iSlice = 1:size(img,3)
for iFrame = 1:size(img, 4)
im = img(:,:,iSlice,iFrame);
extrapVal = mean(im(:));
img(1:2:end,:,iSlice,iFrame) = interp1(ix, im(1:2:end,:)', ...
sin(tx'+rasterPhase)/fillFraction,'linear',extrapVal)';
img(2:2:end,:,iSlice,iFrame) = interp1(ix, im(2:2:end,:)', ...
sin(tx'-rasterPhase)/fillFraction,'linear',extrapVal)';
for iChannel = 1:size(img, 3)
for iSlice = 1:size(img, 4)
for iFrame = 1:size(img, 5)
im = img(:,:, iChannel, iSlice, iFrame);
extrapVal = mean(im(:));
img(1:2:end, :, iChannel, iSlice, iFrame) = interp1(ix, im(1:2:end,:)', ...
sin(tx'+rasterPhase)/fillFraction,'linear',extrapVal)';
img(2:2:end, :, iChannel, iSlice, iFrame) = interp1(ix, im(2:2:end,:)', ...
sin(tx'-rasterPhase)/fillFraction,'linear',extrapVal)';
end
end
end
end
103 changes: 43 additions & 60 deletions lib/+ne7/+scanimage/Reader5.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
% indexed as reader(col, row, frame, slice, channel).
% It works with scanimage 4 and scanimage 5.
%
% The reader can then be addressed with subscripts
% The reader can then be addressed with subscripts
% reader(y, x, channel, slice, frame)
%
% Example:
Expand All @@ -20,7 +20,7 @@
nframes
frames_per_file
end

properties(Dependent)
nslices
channels
Expand All @@ -32,7 +32,7 @@
dwell_time
bidirectional
fill_fraction
is_functional
fastz
end

methods
Expand Down Expand Up @@ -62,7 +62,7 @@
end
end

function f = get.is_functional(self)
function f = get.fastz(self)
if self.scanimage_version == 4
f = 1;
%f = self.header.fastZEnable;
Expand All @@ -75,6 +75,8 @@
function n = get.nslices(self)
if self.scanimage_version == 4
n = self.header.stackNumSlices;
elseif self.header.hFastZ_enable
n = self.header.hFastZ_numFramesPerVolume;
else
n = self.header.hStackManager_numSlices;
%assert(n == self.header.hFastZ_numFramesPerVolume)
Expand Down Expand Up @@ -138,7 +140,7 @@
if self.header.hFastZ_enable
n = self.header.hFastZ_numVolumes;
else
n = hStackManager_framesPerSlice;
n = self.header.hStackManager_framesPerSlice;
end
end

Expand Down Expand Up @@ -173,23 +175,17 @@
end

function sz = size(self)
if self.is_functional
sz(1) = self.header.hRoiManager_linesPerFrame; % not sure this is lines or pixels (JR)
sz(2) = self.header.hRoiManager_pixelsPerLine; % not sure this is lines or pixels (JR)
sz(3) = self.nchannels;
sz(4) = self.nslices;
sz(5) = self.nframes;
else
sz = size(self.data);
end
sz(1) = self.header.hRoiManager_linesPerFrame; % not sure this is lines or pixels (JR)
sz(2) = self.header.hRoiManager_pixelsPerLine; % not sure this is lines or pixels (JR)
sz(3) = self.nchannels;
sz(4) = self.nslices;
sz(5) = self.nframes;
end


function data = subsref(self, S)
if ~strcmp(S(1).type, '()')
data = builtin('subsref', self, S);
elseif ~self.is_functional
data = builtin('subsref', self.data, S);
else
assert(length(S.subs)==5, 'subscript error')
sz = size(self);
Expand Down Expand Up @@ -236,7 +232,7 @@
k=1;
for i=1:length(self.stacks)
stackInd = find(ind(sum(self.frames_per_file(1:i-1))+1 : sum(self.frames_per_file(1:i))));
for j=stackInd
for j=stackInd(:)'
setDirectory(self.stacks{i},j);
f = read(self.stacks{i});
data(:,:,k) = f(yInd,xInd);
Expand All @@ -257,24 +253,25 @@ function compute_nframes(self)
if self.scanimage_version == 4
n = self.header.acqNumFrames;
else
n = (length(self.files)-1) * self.header.hScan2D_logFramesPerFile;

disp('Reading number of frames in last file...');
k=1;
n = (length(self.files)-1) * self.header.hScan2D_logFramesPerFile * self.nchannels;
% Reading number of frames in last file
k=1;
while ~lastDirectory(self.stacks{end})
nextDirectory(self.stacks{end});
k=k+1;
end;
setDirectory(self.stacks{end},1);

n = floor((n + (k / self.nchannels)) / self.nslices);
nextDirectory(self.stacks{end});
k=k+1;
end;
setDirectory(self.stacks{end},1);
n = n + k;

% assert(n == round(n),'Total nframes / nslices must be an integer. Maybe scan aborted?')
end
self.nframes = n;
self.nframes = n/self.nchannels/self.nslices;
if self.nframes ~= round(self.nframes)
warning 'Total nframes / nslices must be an integer. Maybe scan aborted?'
self.nframes = floor(self.nframes);
end
self.frames_per_file(1:length(self.files)-1) = deal(self.header.hScan2D_logFramesPerFile * self.nchannels);
self.frames_per_file(length(self.files)) = n - sum(self.frames_per_file);

self.frames_per_file(length(self.files)) = self.nframes * self.nchannels * self.nslices - sum(self.frames_per_file);
end

function find_files(self, path)
Expand All @@ -295,12 +292,22 @@ function load_header(self)
self.scanimage_version = 5;
temp = regexp(hdr, '^scanimage\.SI\.(?<attr>[\.\w]*)\s*=\s*(?<value>.*\S)\s*$', 'names');
end
framenums = regexp(hdr, '^(?<attr>[\.frameNumbers]*)\s*=\s*(?<value>.*\S)\s*$', 'names');
framenums = [framenums{~cellfun(@isempty, framenums)}];
hdr = temp;
hdr = [hdr{~cellfun(@isempty, hdr)}];
if isempty(hdr) % in case we have used scanimage 5.2
hdr = textscan(tiff.getTag('Software'),'%s','Delimiter',char(10));
hdr = strtrim(hdr{1});
self.scanimage_version = 5.2;
temp = regexp(hdr, '^SI\.(?<attr>[\.\w]*)\s*=\s*(?<value>.*\S)\s*$', 'names');
hdr = temp;
hdr = [hdr{~cellfun(@isempty, hdr)}];
end
hdr(end+1) = framenums;
assert(~isempty(hdr), 'empty header -- possibly wrong ScanImage version.')
self.header = cell2struct(cellfun(@(x) {evaluate(x)}, {hdr.value})', strrep({hdr.attr}, '.', '_'));



function str = evaluate(str)
% if str is not in the form '<value>', then evaluate it.
if str(1)~='<' && str(end)~='>'
Expand All @@ -310,33 +317,9 @@ function load_header(self)
end

function init_stacks(self)
if self.is_functional
self.stacks = arrayfun(@(ifile) ...
Tiff(self.files{ifile}), ...
1:length(self.files), 'uni', false);

%self.stacks = arrayfun(@(ifile) ...
% TIFFStack(self.files{ifile}, [], [self.nchannels self.nslices]), ...
% 1:length(self.files), 'uni', false);

%self.stacks = arrayfun(@(ifile) TIFFStack(self.files{ifile}),1:length(self.files), 'uni', false);
else
% if structural data, then load the entire stack into
% memory. The loaded data is initially flat and needs
% reshaping as well as permutation of axis as frames and
% slices are flipped.
data = [];
for idx = 1:length(self.files)
stack = TIFFStack(self.files{idx}, [], self.nchannels);
data = cat(4, data, stack(:,:,:,:));
end
sz = size(data);
assert(sz(4) == self.nframes * self.nslices, ...
sprintf(['stack size mismatch: expected %d images but only %d '...
'found -- be sure to load all files together'], self.nframes*self.nslices, sz(4)));
sz = [sz(1:end-1) self.nframes self.nslices];
self.data = permute(reshape(data, sz), [1,2,3,5,4]);
end
self.stacks = arrayfun(@(ifile) ...
Tiff(self.files{ifile}), ...
1:length(self.files), 'uni', false);
end

end
Expand Down
Binary file added lib/+ne7/+ui/BW.mat
Binary file not shown.
1 change: 1 addition & 0 deletions lib/+ne7/+ui/csvlist.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
8 changes: 8 additions & 0 deletions lib/+ne7/+ui/drawCells.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ case num2cell('1':'9')
else
removeOutlines
end
case 91
h=findobj(gcf,'type','image');
set(h,'cdata',get(h,'cdata')*.9)
case 93
h=findobj(gcf,'type','image');
set(h,'cdata',get(h,'cdata')*1.1)
case 27
yes = questdlg('Do you wish to abort segmenting this image?','Finish segmentation', 'yes','no','no');
if strcmpi('yes', yes)
Expand All @@ -66,6 +72,8 @@ case num2cell('1':'9')
disp 'Shift-click to delete pixels from mask'
disp 'Press BACKSPACE to undo'
disp 'Press 1-9 to set brush size'
disp '[ to reduce brightness'
disp '] to increase brightness'
disp 'Press SPACE to toggle outlines'
disp 'Press ESC to discard all edits'
disp 'Press ENTER to commit'
Expand Down
1 change: 1 addition & 0 deletions python/commons/bs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

schema = dj.schema('dimitri_brain_state', locals())

schema.spawn_missing_classes()
1 change: 1 addition & 0 deletions python/commons/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
schema = dj.schema('common', locals())


schema.spawn_missing_classes()
88 changes: 88 additions & 0 deletions python/commons/inj.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import datajoint as dj
from commons import virus, mice

schema = dj.schema('common_injections', locals())


@schema
class Site(dj.Lookup):
definition = """
# Injection target site

injection_site : char(8) # ID
---
"""

@property
def contents(self):
yield from zip(['V1', 'dLGN', 'AL', 'LM', 'S1','S2','M1', 'PM','_Test'])


@schema
class AtlasStereotacticTargets(dj.Lookup):
definition = """
# Unadjusted stereotactic coordinates from the mouse brain atlas

->Site
target_id : char(20) # ID for this set of coordinates
---
caudal : double # coordinate caudal from bregma in mm
lateral : double # lateral coordinate in mm
ventral : double # coordinate ventral from cortical surface in mm
lambda_bregma_basedist=4.21 : double # base distance between lambda and bregma from the stereotactic atlas in mm
"""
contents = [
('dLGN', 'Tang2016', 2.6, 2.15, 2.7, 4.21),
('dLGN', 'fabee01', 2.3, 2.25, 2.5, 4.21), # dLGN
('dLGN', 'fabee05', 2.4, 2.25, 2.6, 4.21), # dLGN10302015
('dLGN', 'fabee06', 2.5, 2.5, 2.7, 4.21), # dLGN12032015
('dLGN', 'fabee02', 2.3, 2.4, 2.7, 4.21), # dLGNDeeper
('dLGN', 'fabee03', 2.3, 2.3, 2.6, 4.21), # dLGNmod
('dLGN', 'fabee04', 2.3, 2.4, 2.6, 4.21), # dLGNMoreVentralLateral
('_Test', 'lambda', 4.21, 0, 0, 4.21), # dLGNMoreVentralLateral
('_Test', 'bregma', 0, 0, 0, 4.21), # dLGNMoreVentralLateral
]


@schema
class GuidanceMethod(dj.Lookup):
definition = """
# guidance method for injections

guidance : char(20)
---
"""

@property
def contents(self):
yield from zip(['2P','stereotactic','intrinsic','other'])

@schema
class VirusInjection(dj.Manual):
definition = """
# Virus Injection

-> mice.Mice
-> virus.Virus
-> Site
---
-> GuidanceMethod
volume=null : double # injection volume in nl
speed=null : double # injection speed [nl/min]
toi=CURRENT_TIMESTAMP : timestamp # time of injection
"""

@schema
class InjectionLocation(dj.Manual):
definition = """
# Adjusted stereotactic coordinates for injection

->VirusInjection
->AtlasStereotacticTargets
---
lambda_bregma : double # distance between lambda and bregma in mm as measured
caudal : double # coordinate caudal from bregma in mm
lateral : double # lateral coordinate in mm
ventral : double # coordinate ventral from cortical surface in mm
adjustment : double # adjustement factor to convert atlas coordinates to this injection
"""
Loading