Skip to content

Convert the output of calcGlobalRadiomicsFeatures.m to analyzable matrix format

Aditya P. Apte edited this page Jul 13, 2017 · 1 revision

Convert the output of calcGlobalRadiomicsFeatures.m to an analyzable matrix format

featureFile = FEATURES.mat;
saveFileName = 'file/name/to/write/the/analyzable/matrix/vars/and/IDs.mat';

load(featureFile)

variable={};
data=[];

ID={};
for i=1:length(featureS)
    ID=[ID;featureS(i).fileName];
end


% 1. 'shapeS'
structure = [featureS.shapeS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 2. 'harFeat2DdirS'
structure = [featureS.harFeat2DdirS];
combFeatS = [structure.AvgS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MaxS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

combFeatS = [structure.MinS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.StdS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MadS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 3. 'harFeat2DcombS'
structure = [featureS.harFeat2DcombS];
combFeatS = [structure.CombS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 4. 'harFeat3DdirS'
structure = [featureS.harFeat3DdirS];
combFeatS = [structure.AvgS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MaxS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MinS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.StdS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MadS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


% 5. 'harFeat3DcombS'
structure = [featureS.harFeat3DcombS];
combFeatS = [structure.CombS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 6. 'rlmFeat2DdirS'
structure = [featureS.rlmFeat2DdirS];
combFeatS = [structure.AvgS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MaxS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MinS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

combFeatS = [structure.StdS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MadS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 7. 'rlmFeat2DcombS'
structure = [featureS.rlmFeat2DcombS];
combFeatS = [structure.CombS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 8. 'rlmFeat3DdirS'
structure = [featureS.rlmFeat3DdirS];
combFeatS = [structure.AvgS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

combFeatS = [structure.MaxS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

combFeatS = [structure.MinS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.StdS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


combFeatS = [structure.MadS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


% 9. 'rlmFeat3DcombS'
structure = [featureS.rlmFeat3DcombS];
combFeatS = [structure.CombS];
fieldNamC = fieldnames(combFeatS);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [combFeatS.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 10. 'ngtdmFeatures2dS'
structure = [featureS.ngtdmFeatures2dS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


% 11. 'ngtdmFeatures3dS'
structure = [featureS.ngtdmFeatures3dS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 12. 'ngldmFeatures2dS'
structure = [featureS.ngldmFeatures2dS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 13. 'ngldmFeatures3dS'
structure = [featureS.ngldmFeatures3dS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 14. 'szmFeature2dS'
structure = [featureS.szmFeature2dS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];


% 15. 'szmFeature3dS'
structure = [featureS.szmFeature3dS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 16. 'firstOrderS'
structure = [featureS.firstOrderS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC];
data=[data featM];

% 17. 'peakValleyFeatureS'
structure = [featureS.peakValleyFeatureS];
fieldNamC = fieldnames(structure);
featM = [];
for iField = 1:length(fieldNamC)-2
    featM(:,iField) = [structure.(fieldNamC{iField})]';
end
variable=[variable;fieldNamC(1:2)];
data=[data featM];

% 18. 'ivhFeaturesS'
structure = [featureS.ivhFeaturesS];
Ix=[structure.Ix];
MOHx=[structure.MOHx];
MOCx=[structure.MOCx];
IabsX=[structure.IabsX];
Vx=[structure.Vx];
VabsX=[structure.VabsX];

% variable name
Ix_var={};
for i=1:length(structure(1).xIx)
    Ix_var=[Ix_var; strcat('Ix', num2str(i))];
end

MOHx_var={};
for i=1:length(structure(1).xMOHx)
    MOHx_var=[MOHx_var; strcat('MOHx', num2str(i))];
end

MOCx_var={};
for i=1:length(structure(1).xMOCx)
    MOCx_var=[MOCx_var; strcat('MOCx', num2str(i))];
end

IabsX_var={};
for i=1:length(structure(1).xIabsX)
    IabsX_var=[IabsX_var; strcat('IabsX', num2str(i))];
end

Vx_var={};
for i=1:length(structure(1).xVx)
    Vx_var=[Vx_var; strcat('Vx', num2str(i))];
end

VabsX_var={};
for i=1:length(structure(1).xVabsX)
    VabsX_var=[VabsX_var; strcat('VabsX', num2str(i))];
end

Ix=reshape(Ix,length(Ix_var),[]);
MOHx=reshape(MOHx,length(MOHx_var),[]);
MOCx=reshape(MOCx,length(MOCx_var),[]);
IabsX=reshape(IabsX,length(IabsX_var),[]);
Vx=reshape(Vx,length(Vx_var),[]);
VabsX=reshape(VabsX,length(VabsX_var),[]);

Ix=Ix';
MOHx=MOHx';
MOCx=MOCx';
IabsX=IabsX';
Vx=Vx';
VabsX=VabsX';


dosi_var=[Ix_var;MOHx_var;MOCx_var;IabsX_var;Vx_var;VabsX_var];
dosi_data=[Ix MOHx MOCx IabsX Vx VabsX];

variable=[variable;dosi_var];
data=[data dosi_data];


save(saveFileName, 'data', 'variable', 'ID');
Clone this wiki locally