Skip to content
Snippets Groups Projects
Commit 1c028cde authored by Laura Nervo's avatar Laura Nervo Committed by Nicola Vigano
Browse files

Taper analysis with fable : tools to convert output from fable to matlab variables


Content:
- gtTaperPar2Mat : reads the .par file output from fable and convert it into a matlab structure
- script_generate_files.sh : bach script to read .map file output from the indexing in fable and creates several .txt files with the information separated
- gtTaperConvertFableOutputToDCT : read .txt files and creates a similar "grain" structure (as output from INDEXTER)

Signed-off-by: default avatarLaura Nervo <laura.nervo@esrf.fr>

git-svn-id: https://svn.code.sf.net/p/dct/code/trunk@957 4c865b51-4357-4376-afb4-474e03ccb993
parent c9423b1f
No related branches found
No related tags found
No related merge requests found
function grain = gtTaperConvertFableOutputToDCT(pathtofile)
% grain = gtTaperConvertFableOutputToDCT(pathtofile)
if exist(pathtofile,'file') && ~isempty(pathtofile)
[fable_dir, map_file, ext] = fileparts(pathtofile);
map_file = [map_file ext];
else
fable_dir = 'workspace/grid';
map_file = 'all_smalls_fitted_2.map';
end
% to be run in the analsysis directory
bash_script = fullfile('/users',getenv('USER'),'matlabDCT','zUtil_Taper','script_generate_files.sh');
cmd = [bash_script ' ' fullfile(fable_dir,map_file)];
[~,msg]=unix(cmd);
disp(msg)
fid = fopen(fullfile(fable_dir,'rodrigues.txt'));
C = textscan(fid, '%*s %f %f %f');
fclose(fid);
A = cell2mat(C);
fid = fopen(fullfile(fable_dir,'centers.txt'));
C = textscan(fid, '%*s %f %f %f');
fclose(fid);
A2 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'npeaks.txt'));
C = textscan(fid, '%*s %d');
fclose(fid);
A3 = cell2mat(C);
format longg
fid = fopen(fullfile(fable_dir,'sum_of_all.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A4 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'medians.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A5 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'mins.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A6 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'maxs.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A7 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'means.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A8 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'stds.txt'));
C = textscan(fid, '%f64');
fclose(fid);
A9 = cell2mat(C);
fid = fopen(fullfile(fable_dir,'ns.txt'));
C = textscan(fid, '%d');
fclose(fid);
A10 = cell2mat(C);
grain = [];
for ii = 1:length(A)
grain{ii}.ind = ii;
grain{ii}.R_vector = A(ii,:);
grain{ii}.g = Rod2g( grain{ii}.R_vector );
grain{ii}.angles = gtMathsRod2Euler( grain{ii}.R_vector );
grain{ii}.center = A2(ii,:);
grain{ii}.npeaks = A3(ii);
grain{ii}.allint = A4(ii);
grain{ii}.median = A5(ii);
grain{ii}.min = A6(ii);
grain{ii}.max = A7(ii);
grain{ii}.mean = A8(ii);
grain{ii}.std = A9(ii);
grain{ii}.n = A10(ii);
grain{ii}.stat.intmean = double(grain{ii}.allint);
grain{ii}.stat.bbxsmean = 1;
grain{ii}.stat.bbysmean = 1;
grain{ii}.R_onedge = false;
end
rvec = gtIndexAllGrainValues(grain,'R_vector',[],1:3,[]);
rotmat = gtMathsRod2RotMat( rvec );
for ii=1:length(grain)
grain{ii}.rotmat = rotmat{ii};
end
end % end of function
function parameters = gtTaperPar2Mat(parfile)
fid = fopen(parfile);
C = textscan(fid, '%s %s');
fclose(fid);
index = [];
for ii=1:length(C{2})
patt=regexp(C{2}{ii},'[0-9.e-]','match');
C{3}{ii} = patt;
if length(C{2}{ii})~=length(C{3}{ii})
index(end+1) = ii;
end
end
for ii=index
C{1}(ii) = [];
C{2}(ii) = [];
C{3}(ii) = [];
end
for ii=1:length(C{2})
C{4}{ii} = str2num(C{2}{ii});
end
final = [];
for ii=1:length(C{2})
final.(C{1}{ii}) = C{4}{ii};
end
parameters = final;
end
#!/bin/bash
# input: fabledir/filename.map
CDIR="$PWD"
# define usage function
usage(){
echo "Usage: $0 fabledir/filename.map"
exit 1
}
# define is_file_exits function
# $f -> store argument passed to the script
exist(){
local f="$1"
[[ -f "$f" ]] && return 0 || return 1
}
# invoke usage
# call usage() function if filename not supplied
[[ $# -eq 0 ]] && usage
# less ~vaughan/code/Image/code/image_math.c
# source /sware/exp/fable/bin/fable.bash
#BPATH="/data/id19/graintracking/DCT_Analysis/RD4_15N_taper_"
#DPATH="$BPATH/workspace/grid"
# Invoke is_file_exits
if ( exist "$1" ) && [ -f "$2"];
then
echo "File found"
DPATH=`dirname $1`
FILE=`basename $1`
cd $DPATH
less $FILE | grep Rod > rodrigues.txt
less $FILE | grep trans > centers.txt
less $FILE | grep npks > npeaks.txt
less $FILE | grep intensity > intensities.txt
less intensities.txt | awk -F", " '{print $1}' | awk -F"= " '{print $2}' > sum_of_all.txt
less intensities.txt | awk -F", " '{print $2}' | awk -F"= " '{print $2}' > medians.txt
less intensities.txt | awk -F", " '{print $3}' | awk -F"= " '{print $2}' > mins.txt
less intensities.txt | awk -F", " '{print $4}' | awk -F"= " '{print $2}' > maxs.txt
less intensities.txt | awk -F", " '{print $5}' | awk -F"= " '{print $2}' > means.txt
less intensities.txt | awk -F", " '{print $6}' | awk -F"= " '{print $2}' > stds.txt
less intensities.txt | awk -F", " '{print $7}' | awk -F"= " '{print $2}' > ns.txt
echo "The following txt files have been created in:"
echo $DPATH
ls -ltr *.txt
cd $CDIR
else
echo "File not found"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment