Commit 143c1ed7 authored by jml1g18's avatar jml1g18
Browse files

other libraries to make code independent

parent f13ff8ab
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
folder = 'B:\davis\multiscale\U10test';
outdir = 'J:\FEE\EFMRL\John\190509';
%% get latest folder
dir_list= dir(folder);
dir_list(~[dir_list.isdir]) = [];
%%
for k = 3 : length(dir_list)
%% get name
dname = dir_list(k).name;
xi = sscanf(dname, 'U10_x-axis=%f_x-axis=%f_x-axis=%f');
if length(xi) ~= 3
continue;
end
fname = sprintf('%s/%s/B00001.im7', dir_list(k).folder, dname);
disp(xi);
disp(fname);
disp(exist(fname,'file'));
%% copy
idx = round((xi(1) - 83) / (100/12));
outfile = sprintf('%s/X%02d.im7', outdir, idx);
disp(outfile);
copyfile(fname, outfile);
end
\ No newline at end of file
function [D] = create2DVec( Frame )
Components = Frame.Components;
frameInfo = MakeFrameInfo(Frame);
%Compile vector data
if (frameInfo.hasChoices),
D.C = Components{ frameInfo.best }.Planes{1};
D.U = zeros(size(D.C));
D.V = zeros(size(D.C));
for i=0:4,
mask = (D.C==i);
j = min(i,3);
choiceU = frameInfo.choices(j*3+1);
choiceV = frameInfo.choices(j*3+2);
D.U(mask) = Components{ choiceU }.Planes{1}(mask);
D.V(mask) = Components{ choiceV }.Planes{1}(mask);
end
else
D.U = Components{frameInfo.choices(1)}.Planes{1};
D.V = Components{frameInfo.choices(2)}.Planes{1};
end
Grids = frameInfo.Grids;
scaleX = frameInfo.Scales.X;
scaleY = frameInfo.Scales.Y;
scaleI = frameInfo.Scales.I;
D.U = double(D.U)*scaleI.Slope + scaleI.Offset;
D.V = double(D.V)*scaleI.Slope + scaleI.Offset;
if scaleY.Slope < 0.0, D.V = -D.V; end
%Compile location data
Rx = (1:size(D.U,1))-0.5;
Ry = (1:size(D.U,2))-0.5;
[D.X,D.Y] = ndgrid(Rx*Grids.X*scaleX.Slope + scaleX.Offset, Ry*Grids.Y*scaleY.Slope + scaleY.Offset);
function st = create3DStack (Component)
planes = Component.Planes;
nz = size(planes,1);
if nz >0,
nx = size(planes{1},1);
ny = size(planes{1},2);
st = zeros(nx,ny,nz);
for i=1:nz, st(:,:,i) = planes{i}; end
end
\ No newline at end of file
function [D] = create3DVec( Frame )
Components = Frame.Components;
frameInfo = MakeFrameInfo(Frame);
%Compile best vector data
if (frameInfo.hasChoices),
D.C = create3DStack(Components{ frameInfo.best });
D.U = zeros(size(D.C));
D.V = zeros(size(D.C));
D.W = zeros(size(D.C));
for i=0:5,
mask = (D.C==i);
j = min(i,3);
choiceU = frameInfo.choices(j*3+1);
choiceV = frameInfo.choices(j*3+2);
choiceW = frameInfo.choices(j*3+3);
x = create3DStack(Components{ choiceU });
D.U(mask) = x(mask);
x = create3DStack(Components{ choiceV });
D.V(mask) = x(mask);
x = create3DStack(Components{ choiceW });
D.W(mask) = x(mask);
end
else
D.U = create3DStack(Components{frameInfo.choices(1)});
D.V = create3DStack(Components{frameInfo.choices(2)});
D.W = create3DStack(Components{frameInfo.choices(3)});
end
scaleI = frameInfo.Scales.I;
D.U = double(D.U)*scaleI.Slope + scaleI.Offset;
D.V = double(D.V)*scaleI.Slope + scaleI.Offset;
D.W = double(D.W)*scaleI.Slope + scaleI.Offset;
scaleY = frameInfo.Scales.Y;
if scaleY.Slope < 0.0, D.V = -D.V; end
%Complile location data
Grids = frameInfo.Grids;
scaleX = frameInfo.Scales.X; scaleZ = frameInfo.Scales.Z;
Rx = (1:size(D.U,1))-0.5;
Ry = (1:size(D.U,2))-0.5;
Rz = (1:size(D.U,3))-1.0;
[D.X,D.Y,D.Z] = ndgrid( Rx*Grids.X*scaleX.Slope + scaleX.Offset,...
Ry*Grids.Y*scaleY.Slope + scaleY.Offset,...
Rz*Grids.Z*scaleZ.Slope + scaleZ.Offset);
\ No newline at end of file
function [D]=createPlane( plane, scales )
%Create image data
nx = size(plane,1);
ny = size(plane,2);
D.X = double(1:nx) * scales.X.Slope + scales.X.Offset ;
D.Y = double(1:ny) * scales.Y.Slope + scales.Y.Offset ;
D.I = double(plane) * scales.I.Slope + scales.I.Offset ;
function [D]=createVolume( planeCells, scales )
nz = size(planeCells,1);
if nz < 1, error('invalid number of planes'); end;
nx = size(planeCells{1},1);
ny = size(planeCells{1},2);
%Create location data from scales
rx = double(1:nx) * scales.X.Slope + scales.X.Offset ;
ry = double(1:ny) * scales.Y.Slope + scales.Y.Offset ;
rz = double(1:nz) * scales.Z.Slope + scales.Z.Offset ;
[D.X,D.Y,D.Z] = meshgrid(rx,ry,rz);
%Create volume data from planes
D.I = zeros(nx,ny,nz);
for i=1:nz,
D.I(:,:,i) = planeCells{i}* scales.I.Slope + scales.I.Offset;
end;
function attr_map = readAttributes(imx)
% read attributes into a dictionary
%% extract name/value pairs
attr_names = cellfun(@(a) a.Name, imx.Attributes, 'UniformOutput', false);
attr_values = cellfun(@(a) a.Value, imx.Attributes, 'UniformOutput', false);
%% create map
attr_map = containers.Map;
%% read default keys
n_sources = str2num(readpair(attr_names, attr_values, 'DevDataSources'));
key_list = {'_FrameScale', '_Title', '_DavisVersion', '_Time', '_Date', 'AcqTimeSeries'};
for k = 1 : length(key_list)
attr_map(key_list{k}) = readpair(attr_names, attr_values, key_list{k});
end
%% read device data sources
for n = 0 : n_sources-1
% read properties of data source
name = readpair(attr_names, attr_values, sprintf('DevDataName%d', n));
s = struct();
s.name = name;
s.alias = readpair(attr_names, attr_values, sprintf('DevDataAlias%d', n));
s.scale = readpair(attr_names, attr_values, sprintf('DevDataScale%d', n));
s.class = readpair(attr_names, attr_values, sprintf('DevDataClass%d', n));
s.value = readpair(attr_names, attr_values, sprintf('DevDataTrace%d', n));
% save in hash table
attr_map(name) = s;
end
end
function val = readpair(names, values, key)
i_key = strcmp(names, key);
val = [];
if any(i_key)
val = values{i_key};
end
end
\ No newline at end of file
function [A] = readimxUI( )
A='no file';
%Display located vector field
[f,p] = uigetfile('*.im?');
if ischar(f),
A = readimx([p f]);
showimx(A.Frames{1});
end
[lv_pathstr]= fileparts(which('readimx'));
lv_dirlist = dir([lv_pathstr '/TestImages']);
lv_j=1;
clear A;
for lv_i=1:size(lv_dirlist,1),
if ( ~lv_dirlist(lv_i).isdir)
disp(['Load and display ' lv_dirlist(lv_i).name ' ...'] );
A(lv_j) = readimx([lv_pathstr '/TestImages/' lv_dirlist(lv_i).name]);
figure; showimx(A(lv_j).Frames{1});title(['Image ' num2str(lv_j) ': ' lv_dirlist(lv_i).name]);
lv_j = lv_j+1;
end
end
clear lv_*;
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment