text:
function Az = ComputeAz(meta, percent, pixel_coords)
% COMPUTAZ Compute azimuth angle (angle from north) across spatial frequency
%
% Should work generically for many types of SAR complex data, not just
% spotlight collects.
%
% INPUTS:
%   meta         - required: SICD metadata structure
%   percent      - optional: Array of values from 0 to 100.  Indicates the
%                  fraction across the spatial frequency in azimuth for
%                  which to compute azimuth angle (not including zeropad).
%                  Default is scene center point center of aperture.
%   pixel_coords - optional: [column_index, row_index] (az,rng) index to
%                  point of interest.  Default is scene center point (SCP).
%
% OUTPUTS:
%   Az - computed azimuth angle for each PERCENT value
%
% Author: Wade Schwartzkopf, NGA/IDT
%
% //////////////////////////////////////////
% /// CLASSIFICATION: UNCLASSIFIED       ///
% //////////////////////////////////////////

%% Handle default values for input parameters
% Default for percent is just SCPCOA azimuth
% If percent is not passed, we might not need TimeCOAPoly, so we check this first.
if ~exist('percent','var')
    % SCPCOA.AzimAng is an actual field in latest SICD spec
    if isfield(meta,'SCPCOA') && isfield(meta.SCPCOA,'AzimAng')
        Az = meta.SCPCOA.AzimAng;
        return;
    end
    percent = 50; % If SCPCOA.AzimAng not available, we will compute it.
end
if ~isfield(meta.Grid,'TimeCOAPoly') % TimeCOAPoly field is required
    % For spotlight, we can take some shortcuts with missing metadata
    if isfield(meta,'CollectionInfo') &&...
            isfield(meta.CollectionInfo,'RadarMode')&&...
            isfield(meta.CollectionInfo.RadarMode,'ModeType')&&...
            strcmpi(meta.CollectionInfo.RadarMode.ModeType,'SPOTLIGHT')
        if isfield(meta,'SCPCOA') && isfield(meta.SCPCOA,'SCPTime') &&...
                isfield(meta,'Position') && isfield(meta.Position,'ARPPoly')
            meta.Grid.TimeCOAPoly = meta.SCPCOA.SCPTime;
        elseif isfield(meta,'SCPCOA') && isfield(meta.SCPCOA,'ARPPos') &&...
                isfield(meta.SCPCOA,'ARPVel')
            meta.Grid.TimeCOAPoly = 0;
            meta.Position.ARPPoly.X = [meta.SCPCOA.ARPPos.X; meta.SCPCOA.ARPVel.X];
            meta.Position.ARPPoly.Y = [meta.SCPCOA.ARPPos.Y; meta.SCPCOA.ARPVel.Y];
            meta.Position.ARPPoly.Z = [meta.SCPCOA.ARPPos.Z; meta.SCPCOA.ARPVel.Z];
        end
    end
    if ~isfield(meta.Grid,'TimeCOAPoly')
        error('COMPUTEAZ:TIMECOAPOLY_MISSING','Unable to compute SICD Grid.TimeCOAPoly field from complex data.');
    end
end
% Point of interest (POI) only required for spatially variant COA
if exist('pixel_coords','var') && ~isempty(pixel_coords)
    % Convention for point_slant_to_ground() pixel coordinates is reverse
    % of what is passed to this function (column/row), so we have to swap
    % values.
    poi_ecf = geodetic_to_ecf(point_slant_to_ground([pixel_coords(2); pixel_coords(1)], meta)).';
    % Calculate center of aperture (COA) for given point
    time_coa = sicd_polyval2d(meta.Grid.TimeCOAPoly,pixel_coords(1),pixel_coords(2),meta);
else % Default to SCP
    poi_ecf = [meta.GeoData.SCP.ECF.X, meta.GeoData.SCP.ECF.Y, meta.GeoData.SCP.ECF.Z];
    time_coa = meta.Grid.TimeCOAPoly(1); % SCP COA time is this by definition
    if any(meta.Grid.TimeCOAPoly(2:end)~=0) % Spatially variant COA
        warning('COMPUTEAZ:PIXEL_COORDS_REQUIRED','For non-spotlight data, point of interest must be specified for accurate azimuth angles.');
    end
end

%% Calculate geometry info for center of aperture
pos_coefs=[meta.Position.ARPPoly.X(end:-1:1)...
    meta.Position.ARPPoly.Y(end:-1:1)...
    meta.Position.ARPPoly.Z(end:-1:1)]; % Position polynomial
ARP=[polyval(pos_coefs(:,1),time_coa)...
    polyval(pos_coefs(:,2),time_coa)...
    polyval(pos_coefs(:,3),time_coa)]; % Aperture position at COA
% Velocity polynomial is derivative of position polynomial
vel_coefs=pos_coefs(1:end-1,:).*repmat(((size(pos_coefs,1)-1):-1:1)',[1 3]);
ARV=[polyval(vel_coefs(:,1), time_coa)...
    polyval(vel_coefs(:,2), time_coa)...
    polyval(vel_coefs(:,3), time_coa)]; % Aperture velocity at COA
LOS = poi_ecf - ARP; % Line of site vector at COA
R = norm(LOS); % Range from sensor to POI at COA
V = norm(ARV); % Speed at COA
DCA =  acos((ARV/V)*(LOS.'/R)); % Doppler Cone Angle to POI at COA

%% Compute effective aperture positions for each percentage
Theta = meta.Grid.Col.ImpRespBW/meta.Grid.Row.KCtr; % Angular aperture spanned by this complex image
EffectiveDuration = (Theta*R/V)/sin(DCA); % Theta is expressed as a ratio, rather than an angle
% For the purposes of this computation, we assume a linear flight path
% centered around the COA ARP and ARV, and that the center of the deskewed
% spatial frequency in azimuth is the azimuth angle at COA.
t = EffectiveDuration * ((-1/2) + (percent(:) / 100));
pos = [ARP(1) + (t * ARV(1)), ...
    ARP(2) + (t * ARV(2)), ...
    ARP(3) + (t * ARV(3))];
% We could also compute position given the position given the full position
% polynomial.  However, given that the PERCENT parameter is actually a
% fraction of the spatial frequency space and not time, it is not clear
% that this will be any more accurate.
% t = time_coa + (EffectiveDuration * ((-1/2) + (percent(:) / 100)));
% pos=[polyval(pos_coefs(:,1),t)...
%     polyval(pos_coefs(:,2),t)...
%     polyval(pos_coefs(:,3),t)];

%% Calculate actual azimuth angles
gpn = wgs_84_norm(poi_ecf); % Ground plane normal, based on wgs_84 ellipsoid
range = pos-repmat(poi_ecf,[size(t,1),1]); % Range vectors for each time
north_ground = [ 0 0 1 ]-([ 0 0 1 ]*gpn)*gpn.'; % Project north onto ground plane
range_ground=range-(range*gpn)*gpn.'; % Project range vector onto ground plane
Az = atan2( cross( range_ground, repmat(north_ground,[size(t,1),1]), 2 ) * gpn, ...
    range_ground * north_ground.')*180/pi; % Angle between the two projected vectors
Az(Az < 0) = Az(Az < 0) + 360; % Assure in [0,360], not [-180,180]
Az = reshape(Az,size(percent)); % Reform to shape of original input

end

% //////////////////////////////////////////
% /// CLASSIFICATION: UNCLASSIFIED       ///
% //////////////////////////////////////////

author: ngageoint


text:
function tcm = spm_load_tcm(C)
% tcm = spm_load_tcm(C)
%
% Adapted from SPM function spm_load_priors(V)
% Load the local version of tissue correlation maps for segmentation,
% mainly getting the B-spline coefficients for subsequent sampling using
% B-spline interpolation.
%
% C: local TCM matrix (dim1 x dim2 x dim3 x K x K x 6, dim1~dim3 are same
% as the image size, K is number of tissue types, 6 means 6-neighborhood)
% tcm: a structure for TCM
%
% This function is intended to be used in conjunction with spm_sample_tcm.
% tcm = spm_load_tcm(C);
% C_slice = spm_sample_tcm(tcm,X,Y,Z);
%____________________________________________________________________________
%
% John Ashburner
% Yu (Andy) Huang, 2013-06-04

tiny = eps*eps; % 1e-3; % ANDY 2013-06-05

deg = 1;

% if ~isstruct(V), V  = spm_vol(V); end;
% spm_check_orientations(V);

% =========================NOTE!!!!!!=====================================
% TCM is saved as .mat file only (NOT as NIFTI file).
% Because if NIFTI, it'll have huge size. The header info is NOT needed as
% long as TCM is generated from the same dataset as TPM (then it's already in correct orientation)
% If the dataset that was used to generate TCM does NOT have same header
% info as the TPM NIFTI file, then this interpolation will NOT work
% properly for TCM.
% Therefore, TCM should be generated from the same dataset that was used to
% get TPM, at least header info should be same. % ANDY 2013-06-05
% =========================NOTE!!!!!!=====================================

% tpm.V = V;
% tpm.M = tpm.V(1).mat;

d = size(C);
% Kb = numel(tpm.V);
tcm.dat = cell(d(4:6));

% spm_progress_bar('Init',tpm.V(1).dim(3),'Loading priors','Planes loaded');
% for i=1:tpm.V(1).dim(3)
%     M         = spm_matrix([0 0 i]);
%     s         = zeros(tpm.V(1).dim(1:2));
%     for k1=1:Kb
%         tmp                = spm_slice_vol(tpm.V(k1),M,tpm.V(1).dim(1:2),0);
%         tpm.dat{k1}(:,:,i) = max(min(tmp,1),0);
%         s                  = s + tmp;
%     end;
%     t = s>1;
%     if any(t)
%         for k1=1:Kb
%             tmp           = tpm.dat{k1}(:,:,i);
%             tmp(t)        = tmp(t)./s(t); % normalize the loaded TPM
%             % eTPM.nii will be normalized here. Others (bTPM, cTPM, cTPMthresh) were normalized before loading.
%             tpm.dat{k1}(:,:,i) = tmp;
%         end;
%     end;
%     spm_progress_bar('Set',i);
% end;

tcm.bg1 = zeros(d(4:6));
tcm.bg2 = zeros(d(4:6));
for k=1:d(6)
    for j=1:d(5)
        for i=1:d(4)
            tcm.bg1(i,j,k) = mean(mean(C(:,:,1,i,j,k)));
            tcm.bg2(i,j,k) = mean(mean(C(:,:,end,i,j,k)));
            tcm.dat{i,j,k} = spm_bsplinc(log(C(:,:,:,i,j,k)+tiny),[deg deg deg  0 0 0]);
            % get B-spline coefficients for subsequent sampling using B-spline interpolation

%             tcm.dat{i,j,k} = spm_bsplinc(log(C(2:(end-1),2:(end-1),2:(end-1),i,j,k)+tiny),[deg deg deg  0 0 0]);
%             % here use the 2nd slice and the penultimate slice, because for TCM, it has edge effects, on the edges, some neighbors are not defined.
%             % therefore, edge slices are all discarded when computing B-spline coefficients % ANDY 2013-06-05
        end
    end
end

% tcm.tiny = tiny;
tcm.deg  = deg+1;
% spm_progress_bar('Clear');
return;

author: fieldtrip

repo: fieldtrip

save_path: github-repos/MATLAB/fieldtrip-fieldtrip


text:
function warped_img = mdlt_warping(height, width, img, Hmdlt, offset, X, Y)

warped_img = zeros(height,width,3);
[imgh,imgw,~] = size(img);

for xidx= 1:width
    for yidx = 1:height

        x_grididx = min(find(X >= xidx,1));
        y_grididx = min(find(Y >= yidx,1));

        grididx = (x_grididx-1) * size(Y,2) + y_grididx;
        h = reshape(Hmdlt(grididx,:),3,3);

        x = xidx - offset(1) + 1;
        y = yidx - offset(2) + 1;

        % [_x;_y;1] = H * [x;y;1]
        posz =  h(3,1) * x + h(3,2) * y + h(3,3) ;
        posx = (h(1,1) * x + h(1,2) * y + h(1,3)) ./ posz;
        posy = (h(2,1) * x + h(2,2) * y + h(2,3)) ./ posz;

        if (posx>=1)&&(posx<=imgw)&&(posy>=1)&&(posy<=imgh)
%             warped_img(yidx,xidx,:) = img(posy,posx,:);

            pix = [posy posx];
            float_Y=pix(1)-floor(pix(1));
            float_X=pix(2)-floor(pix(2));

            pix_up_left=[floor(pix(1)) floor(pix(2))];
            pix_up_right=[floor(pix(1)) ceil(pix(2))];
            pix_down_left=[ceil(pix(1)) floor(pix(2))];
            pix_down_right=[ceil(pix(1)) ceil(pix(2))];

            value_up_left   = (1-float_X) * (1-float_Y);
            value_up_right  =     float_X * (1-float_Y);
            value_down_left = (1-float_X) * float_Y;
            value_down_right=     float_X * float_Y;

            warped_img(yidx,xidx,:) = ...
               value_up_left*img(   pix_up_left(1),   pix_up_left(2),:)+ ...
              value_up_right*img(  pix_up_right(1),  pix_up_right(2),:)+ ...
             value_down_left*img( pix_down_left(1), pix_down_left(2),:)+ ...
            value_down_right*img(pix_down_right(1),pix_down_right(2),:);

        else
            warped_img(yidx,xidx,:) = [0,0,0];
        end
    end
end

end

author: YaqiLYU

repo: AANAP

save_path: github-repos/MATLAB/YaqiLYU-AANAP


text:
function [mLMagsig, mHMagsig, fLZmax, fLZmean, fLZmin, fHZmax, fHZmean, fHZmin] =...
    plot_Magsig(mCat1, mCat2 , fPeriod1, fPeriod2, fBinning);
% function [mLMagsig, mHMagsig, fLZmax, fLZmean, fLZmin, fHZmax, fHZmean, fHZmin] =
%           plot_Magsig(mCat1, mCat2 , fPeriod1, fPeriod2, fBinning);
%-----------------------------------------------------------------------------------
% Calculate and plot magnitude signature
%
% Incoming variables:
% mCat1: EQ catalog period 1 (background)
% mCat2: EQ catalog period 2 (foreground)
% fPeriod1 : Length of time period 1 in dec. days
% fPeriod2 : Length of time period 2 in dec. days
% fBinning : Time length of bins in dec. years
%
% Outgoing variables:
% mLMagsig : Matrix of magnitude signature "and below"
% mHMagsig : Matrix of magnitude signature "and above"
% fLZmax   : maximum z-value of mLMagsig
% fHZmax   : maximum z-value of mHMagsig
% fLZmean  : mean z-value of mLMagsig
% fHZmean  : mean z-value of mHMagsig
% fLZmin   : minimum z-value of mLMagsig
% fHZmin   : minimum z-value of mHMagsig
%
% Author: J. Woessner, woessner@seismo.ifg.ethz.ch
% last update: 30.09.02

report_this_filefun(mfilename('fullpath'));

%% Intialize
%% Binnings of time periods
vBinPer1 = min(mCat1(:,3)):fBinning:max(mCat1(:,3));
vBinPer2 = min(mCat2(:,3)):fBinning:max(mCat2(:,3));

fMinMag = floor(min([min(mCat1(:,6)) min(mCat2(:,6))]));
fMaxMag = ceil(max([max(mCat1(:,6)) max(mCat2(:,6))]));
vLMagsig = zeros(size(fMinMag:0.1:fMaxMag));
vHMagsig = zeros(size(fMinMag:0.1:fMaxMag));
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                     Loop over all magnitude bands
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wai = waitbar(0,'Please wait...');
set(wai,'Color',[0.8 0.8 0.8],'NumberTitle','off','Name','Percent completed');
% nmag = length(mmin:0.1:mmax);
nStep = 0;

for i = fMinMag:0.1:fMaxMag
    waitbar(nStep/length(vLMagsig));
    nStep = nStep+1;
    % disp(i)
    %%%%% START computation Magnitude signature for "magnitude and below"
    %% Datata selection
    vSel1 = mCat1(:,6) <= i;
    mTmpCat1 = mCat1(vSel1,:);
    vSel2 = mCat2(:,6) <= i;
    mTmpCat2 = mCat2(vSel2,:);
    if (isempty(mTmpCat1) | isempty(mTmpCat2))
        vLMagsig(nStep) = NaN;
        disp('Not enough data');
    else
        [vCum_TPer1, vBinPer1] = hist(mTmpCat1(:,3),vBinPer1);     %    background
        [vCum_TPer2, vBinPer2] = hist(mTmpCat2(:,3),vBinPer2);     %    foreground
        fMean1 = mean(vCum_TPer1(1:length(vBinPer1)));
        fMean2 = mean(vCum_TPer2(1:length(vBinPer2)));
        fVar1 = cov(vCum_TPer1(1:length(vBinPer1)));
        fVar2 = cov(vCum_TPer2(1:length(vBinPer2)));
        if sqrt(fVar1/length(vBinPer1)+fVar2/length(vBinPer2)) > 0
            vLMagsig(nStep) = (fMean1 - fMean2)/(sqrt(fVar1/length(vBinPer1)+fVar2/length(vBinPer2)));
        end
    end % Check on emptiness
    %%%%% END computation Magnitude signature "magnitudes and below"
    %%%%% START  computation Magnitude signature "magnitudes and above"
    %% Datata selection
    vSel1 = mCat1(:,6) >= i;
    mTmpCat1 = mCat1(vSel1,:);
    vSel2 = mCat2(:,6) >= i;
    mTmpCat2 = mCat2(vSel2,:);
    if (isempty(mTmpCat1) | isempty(mTmpCat2))
        vHMagsig(nStep) = NaN;
        disp('Not enough data');
    else
        [vCum_TPer1, vBinPer1] = hist(mTmpCat1(:,3),vBinPer1);     %    background
        [vCum_TPer2, vBinPer2] = hist(mTmpCat2(:,3),vBinPer2);     %    foreground
        fMean1 = mean(vCum_TPer1(1:length(vBinPer1)));
        fMean2 = mean(vCum_TPer2(1:length(vBinPer2)));
        fVar1 = cov(vCum_TPer1(1:length(vBinPer1)));
        fVar2 = cov(vCum_TPer2(1:length(vBinPer2)));
        if sqrt(fVar1/length(vBinPer1)+fVar2/length(vBinPer2)) > 0
            vHMagsig(nStep) = (fMean1 - fMean2)/(sqrt(fVar1/length(vBinPer1)+fVar2/length(vBinPer2)));
        end
    end % Check on emptiness
end % End for i
close(wai); % Close waitbar

%% Max, mean, min values for "and below"
vMagnitudes = fMinMag:0.1:fMaxMag;
mLMagsig = [vLMagsig' vMagnitudes'];
[fLZmax, nIndMax] = max(mLMagsig(:,1))
[fLZmin, nIndMin] = min(mLMagsig(:,1))
vLZmax = mLMagsig(nIndMax,:);
vLZmin = mLMagsig(nIndMin,:);
vSel = ~isnan(mLMagsig(:,1));
mLMagsigTmp = mLMagsig(vSel,:);
fLZmean = mean(mLMagsigTmp(:,1))

%% Max, mean, min values for "and above"
mHMagsig = [vHMagsig' vMagnitudes'];
[fHZmax, nIndMax] = max(mHMagsig(:,1))
[fHZmin, nIndMin] = min(mHMagsig(:,1))
vHZmax = mHMagsig(nIndMax,:);
vHZmin = mHMagsig(nIndMin,:);
vSel= ~isnan(mHMagsig(:,1));
mHMagsigTmp = mHMagsig(vSel,:);
fHZmean = mean(mHMagsigTmp(:,1))

% Plot
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Start First Plot %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if exist('magsig_fig','var') &  ishandle(magsig_fig)
    set(0,'Currentfigure',magsig_fig);
    disp('Figure exists');
else
    cum_mag_fig=figure_w_normalized_uicontrolunits('tag','magsig','Name','Magnitude signature','Units','normalized','Nextplot','add','Numbertitle','off');
    cum_mag_axs=axes('tag','ax_magsig','Nextplot','add','box','off');
end
set(gca,'tag','ax_magsig','Nextplot','replace','box','off','visible','off');
%axs5=findobj('tag','ax_magsig');
%axes(axs5(1));

vZeroLine = zeros(length(vMagnitudes));
vSig99 = zeros(length(vMagnitudes),2);
vSig99(:,1) = 2.57;
vSig99(:,2) = -2.57;

%% Magnitude signature "And below"
rect = [0.15, 0.15, 0.35, 0.7];
axes('position',rect)
plot(mLMagsig(:,2), mLMagsig(:,1),'r-d');
hold on;
plot(vLZmax(1,2), vLZmax(1,1),'b*');
plot(vLZmin(1,2), vLZmin(1,1),'b*');
plot(vMagnitudes, vSig99(:,1),'g--',vMagnitudes, vSig99(:,2),'g--',vMagnitudes, vZeroLine,'b--');
%% Y-Scale for entire plot
fYmin = floor(min([vLZmin(1,1) vHZmin(1,1) -3]));
fYmax = ceil(max([vLZmax(1,1) vHZmax(1,1) 3]));
axis([fMinMag fMaxMag fYmin fYmax]);
ylabel('z-value');
xlabel('Mag. and below');
%% Magnitude signature "And above"
rect = [0.15+0.35 0.15 0.35 0.7];
axes('position',rect)
plot(mHMagsig(:,2), mHMagsig(:,1),'r-d');
hold on;
plot(vHZmax(1,2), vHZmax(1,1),'b*');
plot(vHZmin(1,2), vHZmin(1,1),'b*');
plot(vMagnitudes, vSig99(:,1),'g--',vMagnitudes, vSig99(:,2),'g--',vMagnitudes, vZeroLine,'b--');
axis([fMinMag fMaxMag fYmin fYmax]);
xlabel('Mag. and above');
set(gca,'YTick',[]);

author: CelsoReyes


text:
function h = quiver(v, d, varargin )
%
% Description
% plots the tangential part of a vector field
%
% Syntax
%   quiver(v,d)
%
% Input
%  v - @vector3d
%  d - @vector3d
%
% Options
%  arrowSize     - length of the arrows
%  autoArrowSize - automatically determine the length of the arrows
%  MaxHeadSize   - size of the head
%
% Output
%
% See also

% initialize spherical plot
opt = delete_option(varargin,{'lineStyle','lineColor','lineWidth','color'},1);
sP = newSphericalPlot(v,opt{:},'doNotDraw');

v = vector3d(v);
if length(d) == length(v), d = reshape(d,size(v)); end

mhs = get_option(varargin,'MaxHeadSize',0.9*(1-d.antipodal));
maxD = max(1e-10,max(reshape(norm(d),[],1)));
scale = 0.01 / maxD;
d = d.orthProj(v);

res = min(15*degree,v.resolution);
if isa(sP(1).proj,'plainProjection')
  arrowSize  = get_option(varargin,'arrowSize', 0.75 * res / degree) / maxD;
else
  arrowSize = get_option(varargin,'arrowSize', 0.5 * res / degree) * degree / maxD;
end

for j = 1:numel(sP)

  holdState = get(sP(j).ax,'nextPlot');
  set(sP(j).ax,'nextPlot','add');

  % project data
  [x0,y0] = project(sP(j).proj,normalize(v),'noAntipodal',varargin{:});
  if check_option(varargin,'centered') || mhs == 0

    [x1,y1] = project(sP(j).proj,normalize(v - scale * d),'noAntipodal',varargin{:});
    [x2,y2] = project(sP(j).proj,normalize(v + scale * d),'noAntipodal',varargin{:});

    % we need to rescale to avoid distortions according to projection
    l = sqrt((x1-x0).^2 + (y1-y0).^2);
    x1 = x0 + (x1-x0) ./ l .* norm(d) .* arrowSize / 2;
    y1 = y0 + (y1-y0) ./ l .* norm(d) .* arrowSize / 2;

    x0 = x0 + (x2-x0) ./ l .* norm(d) .* arrowSize / 2;
    y0 = y0 + (y2-y0) ./ l .* norm(d) .* arrowSize / 2;

  else

    [x1,y1] = project(sP(j).proj,normalize(v + 2*abs(scale) * d),'noAntipodal',varargin{:});

    % we need to rescale to avoid distortions according to projection
    l = sqrt((x0-x1).^2 + (y0-y1).^2);
    x1 = x0 + (x1-x0) ./ l .* norm(d) .* arrowSize;
    y1 = y0 + (y1-y0) ./ l .* norm(d) .* arrowSize;

  end

  % if arrowSize==0 the actual length is taken
  if check_option(varargin,'autoArrowSize')
    arrowSizeArg = {};
  else
    arrowSizeArg = {0};
  end

  % make the quiver plot
  varargin = delete_option(varargin,'parent',1);
  h(j) = optiondraw(quiver(x0,y0,x1-x0,y1-y0,arrowSizeArg{:},'MaxHeadSize',mhs,'parent',sP(j).hgt),varargin{:});     %#ok<AGROW>

  % finalize the plot
  % add annotations
  sP(j).plotAnnotate(varargin{:})
  set(sP(j).ax,'nextPlot',holdState);
end

if any(strcmpi(holdState,{'replaceChildren','replace'})) && isappdata(sP(1).parent,'mtexFig')
  mtexFig = getappdata(sP(1).parent,'mtexFig');
  mtexFig.drawNow('figSize',getMTEXpref('figSize'),varargin{:});
end

if nargout == 0, clear('h'); end

author: mtex-toolbox

repo: mtex

save_path: github-repos/MATLAB/mtex-toolbox-mtex


text:
function rectangle_num = bezier_surface_rectangle_size ( rectangle_file_name )

%*****************************************************************************80
%
%% BEZIER_SURFACE_RECTANGLE_SIZE counts rectangles in a rectangle file.
%
%  Discussion:
%
%    This version of the routine simply counts the number of lines
%    in the file (although it ignores comment lines beginning with "#").
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    19 June 2006
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, string RECTANGLE_FILE_NAME, the name of the
%    rectangle file.
%
%    Output, integer NODE_NUM, the number of rectangles.
%
  rectangle_num = file_row_count ( rectangle_file_name );

  return
end

author: johannesgerer

repo: jburkardt-m


text:
function [dat, W, A, lambda]= proc_ssd(dat, freqs, varargin)
% PROC_SSD - Spatio-Spectral Decomposition for a given frequency band of
% interest
%
%Synopsis:
% [DAT, W, A, LAMBDA]= PROC_SSD(DAT, FREQS, <OPT>)
%
% INPUT:
%     DAT -   data structure of continous data
%     FREQS - 3 x 2 matrix with the cut-off frequencies for the following
%             bands:
%             - first row: pass-band for the signal of interest
%             - second row: pass-band for the noise
%             - third row: stop-band for the noise
%             See the example below.
% OPT - struct or property/value list of optional properties:
%     .filterOrder  -     filter order used for butterworth bandpass and
%                         bandstop filtering. Default: 2
%     .epochIndices -     a matrix of size N x 2, where N is the number of
%                         good (i.e. artifact free) data segments. Each row of
%                         this matrix contains the first and the last sample index of
%                         a data segment, i.e. epoch_indices(n,:) = [1000, 5000]
%                         means that the n'th segment starts at sample 1000 and
%                         ends at sample 5000.
%
% OUTPUT:
% DAT       - updated data structure
% W         - SSD projection matrix (filters are in the columns)
% A         - estimated mixing matrix (spatial patterns are in the columns)
% LAMBDA    - generalized eigenvalue score of SSD objective function
%
%
%
% Description:
% This is a function for the extraction of neuronal oscillations
% with optimized signal-to-noise ratio. The algorithm maximizes
% the power at the center frequency (signal of interest) while simultaneously suppressing it
% at the flanking frequency bins (noise band).
%
% Example for FREQS:
% Let us consider that we want to extract oscillations in the 10-12 Hz
% frequency range. Then we define:
%   freqs = [10 12; 8 14; 9 13].
% The first row defines the frequency band of interest, here 10-12 Hz. The
% second and third row define the pass-pand and stop-band for the noise, respectively.
% Here we have a passband of 8-14 Hz and a stop-band of 9-13 Hz in order
% to get the noise activity just below and just above the band of interest.
%
%
%
% References:
%
% Nikulin VV, Nolte G, Curio G. A novel method for reliable and fast extraction
% of neuronal EEG/MEG oscillations on the basis of spatio-spectral decomposition.
% NeuroImage, 2011, 55: 1528-1535.
%
% Haufe, S., Dahne, S., & Nikulin, V. V. Dimensionality reduction for the
% analysis of brain oscillations. NeuroImage, 2014 (accepted for publication)
% DOI: 10.1016/j.neuroimage.2014.06.073

props= {'filterOrder'   3           'INT'
        'epochIndices'  []          'DOUBLE[- -2]'};

if nargin==0,
  dat = props; return
end

dat = misc_history(dat);
misc_checkType(dat, 'STRUCT(x clab fs)');
opt = opt_proplistToStruct(varargin{:});
opt = opt_setDefaults(opt, props);
opt_checkProplist(opt, props);

%% check if data is segmented or continous
is_epoched = ndims(dat.x) == 3;
if is_epoched
    % if the data is segmented (i.e. epoched), then concatenate epochs
    [Te, Nc, Ne] = size(dat.x);
    dat.x = reshape(permute(dat.x, [1,3,2]), [Te*Ne, Nc]);
end

%% compute SSD
[W, A, lambda, ~, X_ssd] = ssd(dat.x, freqs, dat.fs, opt.filterOrder, opt.epochIndices);

%% store the bandpass-filtered data, projected onto the SSD filters

% make sure to put the data in the correct format
if is_epoched
    X_ssd = permute(reshape(X_ssd, [Te, Ne, size(X_ssd,2)]), [1,3,2]);
end
% store the transformed data
dat.x = X_ssd;

%% rename channel labels and save old channel labels
dat.origClab= dat.clab;
dat.clab=cell(1,size(dat.x,2));
for k=1:size(dat.x,2)
    dat.clab{k} = sprintf('ssd %d',k);
end

author: bbci


text:
function ui = mrViewLoad(ui, pth, type, format, varargin);
% Load a new MR data file / ROI / other data into a mrViewer UI.
%
%   ui = mrViewLoad([ui, pth, type, format, [options]]);
%
% ui: mrViewer UI struct. Finds the most current one if
% omitted.
%
% pth: path to the MR file/s to load. (see mrLoad.)
%
% type: flag for what type of data to load:
%       0 [default]: load the newMR object as the new 'base' newMR object
%                    (stored in the ui.newMR field); the spaces,
%                    as well as any overlays/ROIs/ will need to be
%                    redefined in terms of this new space.
%       1:          load as a map in the ui.maps cell array, to be used
%                   for overlays.
%       2:          load ROI.
%       3:          load space transformation information. Right now,
%                   this means loading a mrSESSION.alignment field. May
%                   become more general in the future.
%       4:          load stimulus files / parfiles.
%       5:          segmentation.
%       6:          mesh.
%       7:          mesh settings file.
% type can also be a string out of:
%   'base', 'map', 'roi', 'space', 'stim', 'segmentation', 'mesh'.
%   'meshsettings'.
%
% format: file format (see mrLoad). Usually, this can be omitted
% and will be inferred from the filename.
%
% For some data types, the code will accept optional additional arguments.
% For instance, when loading a map, the 5th argument can specify which
% sub-volume to load in a map. (E.g., if a map comprises multiple 3-D
% scans, the argument can specify which of these scans to keep, discarding
% the others.)
%
% ras 07/05.
if ~exist('ui','var') | isempty(ui), ui = mrViewGet;            end
if ishandle(ui),                     ui = get(ui,'UserData');   end
if ~exist('type','var') | isempty(type), type = 0;     end
if ~exist('pth', 'var'),		pth = '';						end
if ~exist('format', 'var'),		format = '';					end

typesList = {'base', 'map', 'roi', 'space', 'stim', 'segmentation', ...
	'mesh' 'meshsettings'};

if isnumeric(type), 	type = typesList{type+1};			end

if ~ismember(lower(type), typesList), error('Invalid data type.'); end

% ras 03/07: converted SWITCH statement into a set of sub-functions, to
% make 'em easier to get to.
subfun = sprintf('mrViewLoad%s%s', upper(type(1)), lower(type(2:end)));
if isempty(varargin)
	% evaluate the sub-function without additional options
	ui = feval(subfun, ui, pth, format);
else
	% also pass along the options
	ui = feval(subfun, ui, pth, format, varargin);
end

% update the UI figure
if ishandle(ui.fig)
	set(ui.fig,'UserData',ui);
end

return
% /-----------------------------------------------------------------/ %

% /-----------------------------------------------------------------/ %
function ui = mrViewLoadBase(ui, pth, format, varargin);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load as a base object:
% adjust spaces accordingly. When overlays
% and ROIs are added, will need to adjust these as
% well.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if notDefined('pth')
	ui.mr = mrLoad;
elseif notDefined('format')
	ui.mr = mrParse(pth); % also allow struct
else
	ui.mr = mrLoad(pth, format);
end
ui.spaces = ui.mr.spaces;

return
% /-----------------------------------------------------------------/ %

% /-----------------------------------------------------------------/ %
function ui = mrViewLoadMap(ui, pth, format, varargin);
%%%%%%%%%%%%%%%%%
% load as a map %
%%%%%%%%%%%%%%%%%
if notDefined('pth')
	pth = mrLoad;
elseif ~exist(pth, 'file')
	% check: if the path is a string to a file that can't be
	% found, see if it's relative to a mrVista data directory:
	if ischar(pth) | ~exist(pth, 'file')
		mrGlobals2;
		test = fullfile(dataDir(INPLANE{1}), [pth '.mat']);
		if exist(test, 'file'), pth = test; end
	end
end

if notDefined('format')
	newMR = mrParse(pth);
else
	newMR = mrLoad(pth, format);
end

%%%%%special case: old corAnal files
if isequal(newMR.name,'Coherence') & isequal(newMR.format,'1.0corAnal')
	[co amp ph] = mrReadOldCorAnal(newMR.path);
	ui = mrViewAddMap(ui,co);
	ui = mrViewAddMap(ui,amp);
	ui = mrViewAddMap(ui,ph);
	return
end

% varargin may specify a set of scans from which to take the map
if ~isempty(varargin)
	varargin = unNestCell(varargin);
	scans = varargin{1};
	try
		% find the indices I which correspond to the requested scans
		[scansWithData, I] = intersect(newMR.info.scans, scans);
		if length(scansWithData) < length(scans)
			% can't load all the specified scans? error.
% 			error('Can''t load all selected scans.')
		end

		% sub-select the scan data
		newMR.data = newMR.data(:,:,:,I);
		newMR.dims = size(newMR.data);
		newMR.info.scans = newMR.info.scans(I);
		if prefsVerboseCheck >= 1
			fprintf('[%s]: Loading map data from scans %s.\n', ...
					mfilename, num2str(scans));
		end
	catch
		if prefsVerboseCheck >= 1
			fprintf('[%s]: Couldn''t sub-select scans; loading all scans.\n', ...
					mfilename);
		end
	end
end

% finally, add the new MR data as a map to the UI:
ui = mrViewAddMap(ui, newMR);

return
% /-----------------------------------------------------------------/ %

% /-----------------------------------------------------------------/ %
function ui = mrViewLoadRoi(ui, pth, format, varargin);
%%%%%%%%%%%%
% Load ROI %
%%%%%%%%%%%%
if ~iscell(pth), pth = {pth}; end

for i = 1:length(pth)
	% check: if the path is a string to a file that can't be
	% found, see if it's relative to a mrVista ROI directory:
	if ~check4File(pth{i}, '.mat')
		mrGlobals2;
		test = fullfile(roiDir(INPLANE{1}), [pth{i} '.mat']);
		if exist(test, 'file'), pth{i} = test; end
	end

	if ~check4File(pth{i}, '.mat')
		% still not found? Don't crash, just warn about it.
		warning( sprintf('%s not found.', pth{i}) );
		return
	end

	roi = roiCheckCoords(pth{i}, ui.mr);  % this will load the ROI file
	roi.lineHandles = []; % for drawing ROIs
	roi.prevCoords = []; % for undo
	if isequal(ui.mr.name, 'Inplane')
		roi.viewType = 'Inplane';
		roi.reference = ui.mr.path;
		roi.voxelSize = ui.mr.voxelSize;
	else
		roi.viewType = 'Volume';
		roi.reference = getVAnatomyPath;
		hdr = mrLoadHeader(roi.reference);
		roi.voxelSize = hdr.voxelSize;
	end

	ui = mrViewSet(ui, 'AddROI', roi);
end

return
% /-----------------------------------------------------------------/ %

% /-----------------------------------------------------------------/ %
function ui = mrViewLoadSpace(ui, pth, format, varargin);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load Space Transformation / Alignment %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if isequal(lower(pth), 'dialog')
	% get path with a dialog
	txt = 'Select a mrSESSSION.mat file with the desired alignment';
	pth = mrSelectDataFile('stayput', 'r', '*.mat', txt);
end

[p f ext] = fileparts(pth);
if ~isequal(lower(f), 'mrsession')
	error('Can only load a mrSESSION alignment right now.');
end
load(pth, 'mrSESSION');

% create the new space -- this only works if the base MR object
% is the vAnatomy to which the inplanes were aligned:
ip = mrSESSION.inplanes;
ui.spaces(end+1).name = sprintf('%s Inplanes', mrSESSION.sessionCode);
ui.spaces(end).xform = inv(mrSESSION.alignment);
try
	ifileDir = fullfile(p, 'Raw', 'Anatomy', 'Inplane');
	w = dir(fullfile(ifileDir, 'I*'));
	ifile = fullfile(ifileDir, w(1).name);
	ui.spaces(end).dirLabels = mrIfileDirections(ifile);
catch
	ui.spaces(end).dirLabels = {'Rows' 'Cols' 'Slices'};
end
ui.spaces(end).sliceLabels = {'Rows' 'Cols' 'Slices'};
ui.spaces(end).units = 'Inplane Voxels';
ui.spaces(end).bounds = [1 1 1; ip.cropSize ip.nSlices]';

% add an option for this space in the 'Coordinates' menu
N = length(ui.spaces);
cb = sprintf('mrViewSet([],''Space'',%i); mrViewRefresh;', N);
h = uimenu(ui.menus.space, 'Label',ui.spaces(N).name, ...
	'Checked','off', 'Callback',cb);
ui.spaces(N).menuHandle = h;

return
% /-----------------------------------------------------------------/ %

% /-----------------------------------------------------------------/ %
function ui = mrViewLoadStim(ui, pth, format, varargin);
ui = mrViewAttachStim(ui, pth);
return
% /-----------------------------------------------------------------/ %

% /-----------------------------------------------------------------/ %
function ui = mrViewLoadSegmentation(ui, pth, format, varargin);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load Segmentation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~isempty(pth) & exist(pth, 'file')
	%% load from a saved segmentation file...
	load(pth, 'seg');
	saveFlag = 0;

else
	%% create a segmentation, based on .class and .gray files
	saveFlag = 1; % will offer to save this info below...
	classFilters = {'*lass' 'mrGray Classification File'; ...
					'*nii*' 'NIFTI-format Classification File'; ...
					'*.*' 'All Files'};
	grayFilters = {'*ray' 'mrGray Gray Graph'; ...
				   '*.*' 'All Files'};
	classPath = mrvSelectFile('r', classFilters, 'Select Class File');
	grayPath = mrvSelectFile('r', grayFilters, 'Select Gray Graph');
	[ignore def] = fileparts(fileparts(classPath));
	name = inputdlg('Name of Segmentation?', mfilename, 1, {def});
	if isempty(name), return; else, name = name{1}; end
	seg = segCreate(name, classPath, grayPath);
end

ui = mrViewSet(ui, 'AddSegmentation', seg);

if saveFlag==1
	resp = questdlg(['Do you want to save a small segmentation ' ...
		'file, remembering the paths and name you ' ...
		'selected?'], 'Yes', 'No');
	if isequal(resp, 'Yes')
		seg = ui.segmentation(end);
		segPath = fullfile(fileparts(seg.class), 'segmentation.mat');
		save(segPath, 'seg');
		fprintf('Saved segmentation info in %s.\n', segPath);
	end
end

return
% /-----------------------------------------------------------------/ %

% /-----------------------------------------------------------------/ %
function ui = mrViewLoadMesh(ui, pth, format, varargin);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load Mesh
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~isfield(ui.settings, 'segmentation') | ~isfield(ui, 'segmentation')
	resp = questdlg('No Segmentation installed. Install one now?');
	if isequal(resp, 'Yes')
		ui = mrViewLoad(ui, [], 'segmentation')
	else
		disp('mrViewLoad mesh aborted.'); return
	end
end

s = ui.settings.segmentation;
if isequal(lower(pth), 'firstmesh')
	% special: take the first mesh in the mesh dir
	startDir = ui.segmentation(s).params.meshDir;
	w = what(startDir);
	w.mat = setdiff(w.mat, {'MeshAngles.mat' 'MeshSettings.mat'});
	if isempty(w.mat)
		error( sprintf('No meshes found in %s.', startDir) );
	end
	pth = fullfile(startDir, w.mat{1});
elseif ~exist('pth', 'var') | ~exist(pth, 'file')
	startDir = ui.segmentation(s).params.meshDir;
	pth = mrvSelectFile('r', 'mat', 'Select Mesh File', startDir);
end
if ~exist(pth, 'file'), return; end % user canceled

ui = mrViewAddMesh(ui, mrmReadMeshFile(pth));

return
% /-----------------------------------------------------------------/ %

% /-----------------------------------------------------------------/ %
function ui = mrViewLoadMeshsettings(ui, pth, format, varargin);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Load Mesh Settings
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if notDefined('pth')      % pth is mesh dir in this case
	pth = mrViewGet(ui, 'CurMeshDir');
	if ~exist(pth, 'dir')
		[f pth] = uigetfile('*.mat', 'Select a Mesh Settings File');
	end
end

settingsFile = fullfile(pth, 'MeshSettings.mat');
if exist(settingsFile, 'file')
	load(settingsFile, 'settings');
	names = {settings.name};
	settingsList = findobj('Parent', ui.panels.mesh, 'Style', 'listbox');

	% check that the selected setting is within the range of the new set of
	% settings names
	n = get(settingsList, 'Value');
	if n > length(names), n = length(names); end

	set(settingsList, 'String', names, 'Value', n);
else
	warning( sprintf('Couldn''t find mesh settings file %s.', settingsFile) );
end
return

author: vistalab

repo: vistasoft

save_path: github-repos/MATLAB/vistalab-vistasoft


text:
Network Resnet50 {
	Layer CONV1 {
		Type: CONV
		Stride { X: 2, Y: 2 }
		Dimensions { K: 64, C: 3, R: 7, S: 7, Y:224, X:224 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(14,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_1_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 64, C: 64, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_1_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 64, C: 64, R: 3, S: 3, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_1_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 64, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_1_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 256, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_2_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 64, C: 256, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_2_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 64, C: 64, R: 3, S: 3, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_2_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 64, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_2_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 256, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_3_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 64, C: 256, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_3_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 64, C: 64, R: 3, S: 3, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_3_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 64, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV2_3_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 256, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_1_1 {
		Type: CONV
		Stride { X: 2, Y: 2 }
		Dimensions { K: 128, C: 256, R: 1, S: 1, Y: 56, X: 56 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_1_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 128, C: 128, R: 3, S: 3, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_1_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 128, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_1_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 512, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_2_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 128, C: 256, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_2_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 128, C: 128, R: 3, S: 3, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_2_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 128, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_1_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 512, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_3_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 128, C: 256, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_3_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 128, C: 128, R: 3, S: 3, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_3_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 128, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_3_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 512, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_4_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 128, C: 256, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_4_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 128, C: 128, R: 3, S: 3, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_4_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 128, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV3_4_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 512, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_1_1 {
		Type: CONV
		Stride { X: 2, Y: 2 }
		Dimensions { K: 256, C: 512, R: 1, S: 1, Y: 28, X: 28 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_1_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_1_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1024, C: 256, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_1_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_2_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_2_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_2_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1024, C: 256, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_2_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_3_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_3_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_3_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1024, C: 256, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_3_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_4_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_4_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_4_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1024, C: 256, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_4_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_5_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_5_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_5_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1024, C: 256, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_5_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_6_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_6_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 256, C: 256, R: 3, S: 3, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_6_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1024, C: 256, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV4_6_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_1_1 {
		Type: CONV
		Stride { X: 2, Y: 2 }
		Dimensions { K: 512, C: 1024, R: 1, S: 1, Y: 14, X: 14 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_1_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_1_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 2048, C: 512, R: 1, S: 1, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_1_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 2048, R: 1, S: 1, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_2_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 2048, R: 1, S: 1, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_2_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_2_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 2048, C: 512, R: 1, S: 1, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_2_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 2048, R: 1, S: 1, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_3_1 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 2048, R: 1, S: 1, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_3_2 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 512, C: 512, R: 3, S: 3, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(10,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_3_3 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 2048, C: 512, R: 1, S: 1, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer CONV5_3_Residual {
		Type: DSCONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1, C: 2048, R: 1, S: 1, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

	Layer FC1000 {
		Type: CONV
		Stride { X: 1, Y: 1 }
		Dimensions { K: 1000, C: 2048, R: 7, S: 7, Y: 7, X: 7 }
		Dataflow {
			TemporalMap(1,1) K;
			TemporalMap(1,1) C;
			SpatialMap(Sz(R), 1) Y;
			TemporalMap(8,8) X;
			Cluster(8, P);
			SpatialMap(Sz(S), 1) X;
			TemporalMap(Sz(R), Sz(R)) R;
			TemporalMap(Sz(R), Sz(R)) S;
		}

	}

}

author: maestro-project

repo: maestro


text:
function diagX = cdiag(X)
% Extracts the diagonal elements of A.
%
% function diagX = cdiag(X)
%
% Returns the diagonal elements of A. The input A does not necessarily
% to be a square matrix. The function supports both numeric arrays and
% structs with fields real and imag. Note that diag currently does
% not support dlarrays and cdiag can be seen as a backup function.
%
% See also: manoptADhelp

% This file is part of Manopt: www.manopt.org.
% Original author: Xiaowen Jiang, Aug. 31, 2021.
% Contributors: Nicolas Boumal
% Change log:

    if iscstruct(X)
        assert(length(size(X.real)) == 2, 'Input should be a 2-D array')
        m = size(X.real,1);
        n = size(X.real,2);
        realX = X.real;
        imagX = X.imag;
        if n >= m
            diagX.real = realX(1:m+1:m^2);
            diagX.imag = imagx(1:m+1:m^2);
        else
            diagX.real = realX(1:m+1:m*n-m+n);
            diagX.imag = imagX(1:m+1:m*n-m+n);
        end

    elseif isnumeric(X)
        assert(length(size(X)) == 2, 'Input should be a 2-D array')
        m = size(X,1);
        n = size(X,2);
        if n >= m
            diagX = X(1:m+1:m^2);
        else
            diagX = X(1:m+1:m*n-m+n);
        end

    else
        ME = MException('cdiag:inputError', ...
                        'Input does not have the expected format.');
        throw(ME);
    end

end

author: NicolasBoumal

repo: manopt


text:
function p=v_mos2pesq(m)
%V_MOS2PESQ convert MOS speech quality scores to PESQ p=(m)
%Inputs:    m  is a matrix of MOS scores
%
%Outputs:   p  is a matrix, the same size as m, of PESQ scores
%
% The PESQ measure is defined in [2]. The mapping function, defined in [3],
% converts raw PESQ scores (which lie in the range -0.5 to 4.5) onto the
% MOS-LQO (Mean Opinion Score - Listening Quality Objective [2]) scale in the
% range 1 to 5. The MOS scale is defined in [1] as
%           5=Excellent, 4=Good, 3=Fair, 2=Poor, 1=Bad.
%
% Refs: [1]	ITU-T. Methods for subjective determination of transmission quality.
%           Recommendation P.800, Aug. 1996.
%       [2]	ITU-T. Mean opinion score (MOS) terminology.
%           Recommendation P.800.1, July 2006.
%       [2]	ITU-T. Perceptual evaluation of speech quality (PESQ), an objective
%           method for end-to-end speech quality assessment of narrowband telephone
%           networks and speech codecs. Recommendation P.862, Feb. 2001.
%       [3]	ITU-T. Mapping function for transforming P.862 raw result scores to MOS-LQO.
%           Recommendation P.862.1, Nov. 2003.

%      Copyright (C) Mike Brookes 2012-2013
%      Version: $Id: v_mos2pesq.m 10865 2018-09-21 17:22:45Z dmb $
%
%   VOICEBOX is a MATLAB toolbox for speech processing.
%   Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   This program is free software; you can redistribute it and/or modify
%   it under the terms of the GNU General Public License as published by
%   the Free Software Foundation; either version 2 of the License, or
%   (at your option) any later version.
%
%   This program is distributed in the hope that it will be useful,
%   but WITHOUT ANY WARRANTY; without even the implied warranty of
%   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%   GNU General Public License for more details.
%
%   You can obtain a copy of the GNU General Public License from
%   http://www.gnu.org/copyleft/gpl.html or by writing to
%   Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
persistent a b c d
if isempty(a)
    a=0.999;
    b=4.999-a;
    c=-1.4945;
    d=4.6607;
end
if nargout>0
    p=(log(b./(m-a)-1)-d)/c;
else
    if nargin<1 || isempty(m)
        pp=linspace(-0.5,4.5,100);
        mm=v_pesq2mos(pp);
    else
        mm=m;
    end
    p=v_mos2pesq(mm);
    plot(mm,p);
    ylabel('PESQ (P.862)');
    xlabel('Mean Opimion Score (MOS)');
end

author: ImperialCollegeLondon

repo: sap-voicebox


text:
function q = repmat(q,varargin)
% overloads repmat

q.a = repmat(q.a,varargin{:});
q.b = repmat(q.b,varargin{:});
q.c = repmat(q.c,varargin{:});
q.d = repmat(q.d,varargin{:});


%==============================================================================
% This code is part of the Matlab-based toolbox
% FAIR - Flexible Algorithms for Image Registration.
% For details see
% - https://github.com/C4IR and
% - http://www.siam.org/books/fa06/
%==============================================================================
%
% Tutorial for FAIR: various distances versus rotation angle
%
%   - data                 xrays of hands, Omega=(0,20)x(0,25), level=6, m=[128,128]
%   - viewer               viewImage2D
%   - interpolation        splineInter
%   - distance             {'SSD','NCC','MI','NGF'}
%   - transformation       rotation2D
% see also E7_Hands_distance_rotation
%==============================================================================

clear, close all, help(mfilename);

% setup data
setup2DPETCTData; level = 6; omega = ML{level}.omega; m = ML{level}.m;

DM = {'SSD','NCC','MImex','NGFdot'};

str = @(w) sprintf('T(y(%s^o))',num2str(w*180/pi));
variable = @(k)['DM',DM{k}];

theta = [0,10];

for q=1:length(theta),
    fprintf('============== %s ====================\n\n',...
      sprintf('theta=%s',num2str(theta(q))));

    % initialize interpolation [spline] and troansformation [rotation]
    imgModel('reset','imgModel','splineInter','regularizer','moments','theta',theta(q));
    [T,R] = imgModel('coefficients',ML{level}.T,ML{level}.R,omega);
    X  = getCellCenteredGrid(omega,m);
    Rc = imgModel(R,omega,X);
    center = (omega(2:2:end)-omega(1:2:end))'/2;
    trafo('reset','trafo','rotation2D','c',center);
    trafo('w0');

    % run loo over the following distance measures
    edge = 10;
    filename = fullfile(FAIRpath,'temp',...
      sprintf('%s-%s-theta=%s.mat',mfilename,'rot',num2str(theta(q))));
    if ~exist(filename,'file'),
      w = pi/2*linspace(-1,1,101)';
      save(filename,'w','DM');
    else
      clear DM*
      load(filename)
    end;

    for k=1:length(DM),
      var = whos('-file',filename);
      j = find(strcmp({var(:).name},variable(k))==1);

      if isempty(j),
        fprintf('============== %s ====================\n\n',variable(k))
        disp([variable(k),'=dm;']);
        dm = zeros(size(w));
        for j=1:length(w),
          Y = trafo(w(j),X(:));
          Tc = imgModel(T,omega,Y);
          dm(j) = feval(DM{k},Tc,Rc,omega,m,'edge',edge);
          if j == 1,
            figure(k); clf;
            subplot(1,3,1); viewImage(Rc,omega,m); title('reference');
            subplot(1,3,2); ph = viewImage(Tc,omega,m); th = title(str(w(j)));
            subplot(1,3,3); rh = plot(w(j),dm(j),'r.','markersize',20);
            axis([w(1),w(end),-inf,inf]); hold on;      title(DM{k})
            axis('auto y')
          else
            set(ph,'cdata',reshape(Tc,m)'); set(th,'string',str(w(j)));
            subplot(1,3,3); set(rh,'visible','off');
            plot(w(1:j),dm(1:j),'k-','linewidth',2);
            rh = plot(w(j),dm(j),'r.','markersize',20);    pause(1/100)
          end;
          fprintf('.'); if ~rem(j,50) || j==length(w), fprintf('\n'); end;
        end;
        eval([variable(k),'=dm;']);
        save(filename,'-append',variable(k));
        fprintf('============== %s done ===============\n\n',variable(k))
      end;
    end;

    Name = @(k) sprintf('%s-theta=%s',DM{k},num2str(theta(q)));
    for k=1:4,
      eval(['dm=',variable(k),';']);
      dm = dm(1:length(w));
      [wOpt,j] = min(dm);
      FAIRfigure(k);
      ph = plot(w,dm,'-',w(j),dm(j),'*');
      set(ph,'linewidth',2,'color','k','markersize',20);
      set(gca,'fontsize',30);
      a = max(dm)-0.2*(max(dm)-min(dm));
      th = text(w(j),a,['$w^*=',num2str(w(j)),'$']);
      set(th,'fontsize',30,'interpreter','latex','horizontalalignment','center');
    end;
    fprintf('=====================================================================\n');

end;
return
% =========================================================================


text:
%combfirst Returns the first combination in order of shifting the least left
%number to the right.
%
%  function com=combfirst(n, k)
%
%n and k has the meaning of combination number.
function com=combfirst(n, k)

com=find(1 == ones(1,k-1));
com=[com k-1];

return

author: strawlab

repo: MultiCamSelfCal


text:
function [model] = generateRules(model, printLevel)
% If a model does not have a model.rules field but has a model.grRules
% field, can be regenerated using this script
%
% USAGE:
%
%    [model] = generateRules(model)
%
% INPUT:
%    model:        COBRA model with model.grRules
%    printLevel:   optional variable to print out all new genes
%                  (default = TRUE), can be zero if not needed
%
% OUTPUT:
%    model:     same model but with model.rules added
%
% .. Author: - Aarash Bordar 11/17/2010
%            - Uri David Akavia 6-Aug-2017, bug fixes and speedup
%            - Diana El Assal 30/8/2017
%            - Laurent Heirendt December 2017, speedup

if ~exist('printLevel', 'var')
    printLevel = 1;
end
if ~isfield(model, 'grRules')
    warning('generateRules can be only be used on a model that has grRules field!');
    return;
end
[preParsedGrRules,genes] = preparseGPR(model.grRules);  % preparse all model.grRules
allGenes =  unique([genes{~cellfun(@isempty,genes)}]); %Get the unique gene list
if (~isfield(model, 'genes'))
    newGenes = allGenes;
else
    %         C = setdiff(A,B) for vectors A and B, returns the values in A that
    %         are not in B with no repetitions. C will be sorted.
    newGenes = setdiff(allGenes,model.genes);
end
if ~isempty(newGenes)
    if printLevel
        warning('Found the following genes in grRules that were not present in model.genes:\n%s\nAdding them to the model.',strjoin(newGenes,'\n'));
    end
    model = addGenes(model,newGenes);
end

% determine the number of rules
nRules = length(model.grRules);

% allocate the model.rules field
model.rules = cell(nRules, 1);
% loop through all the grRules
for i = 1:nRules
    if ~isempty(preParsedGrRules{i})
        genePos = zeros(numel(genes{i}));
        for j = 1:numel(genes{i})
            genePos(j) = find(strcmp(model.genes,genes{i}{j}));
        end
        rule = parseGPR(preParsedGrRules{i}, genes{i}, true, genePos);
        model.rules{i, 1} = rule;
    else
        model.rules{i, 1} = '';
    end
end
end

author: opencobra

repo: cobratoolbox


text:
function afthlp() % autogenerated function wrapper
%Opens an explanation file for aftershock analysis.
 % turned into function by Celso G Reyes 2017

ZG=ZmapGlobal.Data; % used by get_zmap_globals
open('afthelp');

end


text:
function value = cone_volume_3d ( r, h )

%*****************************************************************************80
%
%% CONE_VOLUME_3D returns the volume of a cone in 3D.
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    20 May 2004
%
%  Author:
%
%    John Burkardt
%
%  Parameters:
%
%    Input, real R, the radius of the base of the cone.
%
%    Input, real H, the height of the cone.
%
%    Output, real CONE_VOLUME_3D, the volume of the cone.
%
  value = ( pi / 3.0 ) * h * r * r;

  return
end


text:
% - This function is part of ERPLAB Toolbox -
%

function ind = beh_scripts_good_cells(mycell)
% Find good cells

if ~iscell(mycell)
        mycell = {mycell};
end

ind = cellfun('isempty', mycell);

% Good cells
ind = (ind == 0);

% Convert ind to row vector
ind = ind(:)';

author: ucdavis

repo: erplab

save_path: github-repos/MATLAB/ucdavis-erplab


text:
function [m,s] = mean_std_robust(x);

x = x(:);

m = median(x);

s = median(abs(x - m))*1.4836;

repo: ekfmonoslam


text:
% The function used with the program: Quadrotor control

function xdot = quad_control_fn(t,x)

global Jtp Ixx Iyy Izz b d l m g Kpz Kdz Kpp Kdp Kpt Kdt Kpps Kdps ZdF PhidF ThetadF PsidF ztime phitime thetatime psitime Zinit Phiinit Thetainit Psiinit Uone Utwo Uthree Ufour Ez Ep Et Eps

% The desired values
% Changes in Z start at t = 3, changes in Phi start at t = 1, changes in
% Theta start at the origin, and chanfes in Psi start at t= 2
% If you want that all start at the origin simply remove the conditions

% time for change start of each variable
ztime = 3;
phitime = 1;
thetatime = 0.2;
psitime = 2;
%%% HEIGHT %%%
if t < ztime
 Zd = Zinit;
end

if t >= ztime
 Zd = ZdF;
end
%%%%%%%%%%%%%%
%%% Phi %%%
if t < phitime
 Phid = Phiinit;
end

if t >= phitime
 Phid = PhidF;
end
%%%%%%%%%%%%%%
%%% Theta %%%
if t < thetatime
 Thetad = Thetainit;
end

if t >= thetatime
 Thetad = ThetadF;
end
%%%%%%%%%%%%%%
%%% Psi %%%
if t < psitime
 Psid = Psiinit;
end

if t >= psitime
 Psid = PsidF;
end
%%%%%%%%%%%%%%

PsidF = 2*pi;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

thetaddot = 0;
phiddot = 0;
psiddot = 0;
Zddot = 0;
% Zd = 10;

    % Bounding the angles within the -2*pi / 2*pi range
    if (x(7)> 2*pi || x(7)< - 2*pi)
        x(7) = rem(x(7),2*pi);
    end

    if (x(9)> 2*pi || x(9)< - 2*pi)
        x(9) = rem(x(9),2*pi);
    end

    if (x(11)> 2*pi || x(11)< - 2*pi)
        x(11) = rem(x(11),2*pi);
    end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%PD-Z-Control%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Evaluate the Controls
    U = [];    % The control vector
    U(1) = m*(g + Kpz*(Zd - x(5)) + Kdz*( - x(6)))/(cos(x(9))*cos(x(7)));   % Total Thrust on the body along z-axis
    U(2) = (Kpp*(Phid - x(7)) + Kdp*( - x(8)));   % Roll input
	U(3) = (Kpt*(Thetad - x(9)) + Kdt*( - x(10)));   % Pitch input
	U(4) = (Kpps*(Psid - x(11)) + Kdps*( - x(12)));   % Yawing moment

    U = real(U);
    U = [U(1);U(2);U(3);U(4)];    % The control vector

%     % Bounding the controls
%     if U(1) > 15.7
%         U(1) = 15.7;
%     end
%
%     if U(1) < 0
%         U(1) = 0;
%     end
%
%     for j = 2:4
%         if U(j) > 1
%         U(j) = 1;
%         end
%
%         if U(j) < -1
%         U(j) = -1;
%         end
%     end

    % Calculation of angular velocities
    omegasqr(1) = (1/4*b)*U(1) + (1/2*b*l)*U(3) - (1/4*d)*U(4);
    omegasqr(2) = (1/4*b)*U(1) - (1/2*b*l)*U(2) + (1/4*d)*U(4);
    omegasqr(3) = (1/4*b)*U(1) - (1/2*b*l)*U(3) - (1/4*d)*U(4);
    omegasqr(4) = (1/4*b)*U(1) + (1/2*b*l)*U(2) + (1/4*d)*U(4);
    omegasqr = real(omegasqr);

    omega(1) = sqrt(omegasqr(1));
    omega(2) = sqrt(omegasqr(2));
    omega(3) = sqrt(omegasqr(3));
    omega(4) = sqrt(omegasqr(4));
        % Bounding the angular velocities
    for j = 1:4
        if omega(j) > 523
            omega(j) = 523;
        end

        if omega(j) < 125
            omega(j) = 125;
        end
    end
    omegasqr(1) = (omegasqr(1))^2;
    omegasqr(2) = (omegasqr(2))^2;
    omegasqr(3) = (omegasqr(3))^2;
    omegasqr(4) = (omegasqr(4))^2;
%     % Bounding the angular velocities
%     for j = 1:4
%         if omegasqr(j) > 523
%             omegasqr(j) = 523;
%         end
%
%         if omegasqr(j) < 125
%             omegasqr(j) = 125;
%         end
%     end
    % Disturbance
    Omega = d*(- sqrt(omegasqr(1)) + sqrt(omegasqr(2)) - sqrt(omegasqr(3)) + sqrt(omegasqr(4)));

% Evaluation of the State space wrt H-frame
    xdot(1) = x(2); % Xdot
    xdot(2) = (sin(x(11))*sin(x(7)) + cos(x(11))*sin(x(9))*cos(x(7)))*(U(1)/m);    % Xdotdot
    xdot(3) = x(4); % Ydot
    xdot(4) = (-cos(x(11))*sin(x(7)) + sin(x(11))*sin(x(9))*cos(x(7)))*(U(1)/m);	% Ydotdot
    xdot(5) = x(6); % Zdot
    xdot(6) = - g + (cos(x(9))*cos(x(7)))*(U(1)/m);    % Zdotdot
    xdot(7) = x(8); % phydot
    xdot(8) = ((Iyy - Izz)/Ixx)*x(10)*x(12) - (Jtp/Ixx)*x(10)*Omega + (U(2)/Ixx); % pdot = phydotdot
    xdot(9) = x(10);    % thetadot
    xdot(10) = ((Izz - Ixx)/Iyy)*x(8)*x(12) + (Jtp/Iyy)*x(8)*Omega + (U(3)/Iyy);	% qdot = thetadotdot
    xdot(11) = x(12);   % thetadot
    xdot(12) = ((Ixx - Iyy)/Izz)*x(8)*x(10) + (U(4)/Izz);	% rdot = psidotdot

xdot = xdot';

author: Sable

repo: mcbench-benchmarks


text:
function G = getGroupSuperColor27(I, param)

    N = size(I,1) * size(I, 2);

    g = sparse(N, N);

    imlab = vl_xyz2lab(vl_rgb2xyz(I)) ;
    imlab = single(imlab);
    slicParam = param.superpixel.slicParam;

    groupCount = 0;
    for i=1:size(slicParam,1)

        segments = vl_slic(imlab, slicParam(i,1),  slicParam(i,2)) ;
        segments = segments(:);

        maxLabel = max(segments);
        for j = 0:maxLabel
            g(:, groupCount+j+1) = segments==j;
        end
        groupCount  = groupCount+ maxLabel+1;

    end

    % croping G
    g =g(:, 1:groupCount);

    G = [g;g;g];

end

author: andrewssobral

repo: lrslibrary


text:
% RESAMPLE_SCAT Resample a scattering transform.
%
% Usages
%    S = RESAMPLE_SCAT(S, res, preserve_energy)
%
% Input
%    S (cell): A scattering transform.
%    res (int): The desired resolution.
%    preserve_energy (bool, optional): If set, renormalizes each resampled
%       coefficient so that its energy (sum of squares) remains the same.
%
% Output
%    S (cell): The scattering transform with each coefficient resampled to
%       resolution res.
%
% Description
%    Each coefficient in S is resampled to have the proper resolution. If the
%    desired resolution is finer, the signal will be interpolated. If the
%    resolution is coarser, it will be downsampled.
%
% See also
%    LOG_SCAT

function S = resample_scat(S, res, preserve_energy)
	if nargin < 3
		preserve_energy = true;
	end

	if iscell(S)
		for m = 0:length(S)-1
			S{m+1} = resample_scat(S{m+1}, res, preserve_energy); % self-call
        end
		return;
    end

	for p1 = 1:length(S.signal)
		res1 = 0;
		if isfield(S.meta,'resolution')
			res1 = S.meta.resolution(p1);
		end
		sz_orig = size(S.signal{p1});
		S.signal{p1} = interpft(S.signal{p1}, 2^(-res+res1)*size(S.signal{p1},1));
		sz_new = sz_orig;
		sz_new(1) = sz_orig(1)*2^(-res+res1);
		S.signal{p1} = reshape(S.signal{p1}, sz_new);
		if preserve_energy
			S.signal{p1} = S.signal{p1}*2^(-(-res+res1)/2);
		end
		S.meta.resolution(p1) = res;
	end
end

author: scatnet

repo: scatnet

save_path: github-repos/MATLAB/scatnet-scatnet


text:
%%
%
% Return normalized probs as well as scores (numerators in log domain) & norms.
% Note that scores & norms are subtracted/scaled by a constant factor.
%
% Here, we only work on a subset linearIds of the raw scores.
%
% Thang Luong @ 2015, <lmthang@stanford.edu
%
%%
function [probs, scores, norms] = normLayerForward(rawScores, maskedIds)
  % rawScores: numPositions * batchSize
  scores = rawScores;
  scores(maskedIds) = 0;

  % subtract max elements, scores: numClasses * ...
  mx = max(scores, [], 1);
  scores = bsxfun(@minus, scores, mx);

  % probs
  probs = exp(scores);
  probs(maskedIds) = 0;

  norms = sum(probs, 1); % normalization factors
  norms(norms==0) = 1; % for zero columns, set to 1.
  probs = bsxfun(@rdivide, probs, norms); % normalize
end

author: lmthang