Skip to content

Commit

Permalink
NUCLEUSinv update
Browse files Browse the repository at this point in the history
1. extended the BAM NMR tomograph import routine to handle data files that do not belong to a *lift*-set (i.e. do not have a z-position defined in the par-file)
2. bug fix: when importing a *LIAG* project where the calibration file is already inverted, and hence, automatically imported, the relaxation time was not used as *Tbulk* time for the sample
  • Loading branch information
ThoHiller committed Jun 27, 2019
1 parent 923fe2d commit 7ab6650
Show file tree
Hide file tree
Showing 14 changed files with 1,103 additions and 1,017 deletions.
4 changes: 2 additions & 2 deletions NUCLEUSinv/NUCLEUSinv.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
if ~isempty(h0); close(h0); end

%% GUI 'header' info and defaults
myui.version = '0.1.5';
myui.date = '27.03.2019';
myui.version = '0.1.7';
myui.date = '27.06.2019';
myui.author = 'Thomas Hiller';
myui.email = 'thomas.hiller[at]leibniz-liag.de';
myui.fontsize = 10;
Expand Down
2 changes: 1 addition & 1 deletion NUCLEUSinv/NUCLEUSinv_updateInterface.m
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@
'String',num2str(data.param.sampVol));
end

% Matlab need some time
% Matlab needs some time
pause(0.001);

end
Expand Down
4 changes: 2 additions & 2 deletions NUCLEUSmod/NUCLEUSmod.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
if ~isempty(h0); close(h0); end

%% GUI 'header' info and defaults
myui.version = '0.1.5';
myui.date = '27.03.2019';
myui.version = '0.1.7';
myui.date = '27.06.2019';
myui.author = 'Thomas Hiller';
myui.email = 'thomas.hiller[at]leibniz-liag.de';
myui.fontsize = 10;
Expand Down
4 changes: 2 additions & 2 deletions doc/nucleus/NUCLEUSinv/NUCLEUSinv.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0038 <span class="keyword">if</span> ~isempty(h0); close(h0); <span class="keyword">end</span>
0039
0040 <span class="comment">%% GUI 'header' info and defaults</span>
0041 myui.version = <span class="string">'0.1.5'</span>;
0042 myui.date = <span class="string">'27.03.2019'</span>;
0041 myui.version = <span class="string">'0.1.7'</span>;
0042 myui.date = <span class="string">'27.06.2019'</span>;
0043 myui.author = <span class="string">'Thomas Hiller'</span>;
0044 myui.email = <span class="string">'thomas.hiller[at]leibniz-liag.de'</span>;
0045 myui.fontsize = 10;
Expand Down
2 changes: 1 addition & 1 deletion doc/nucleus/NUCLEUSinv/NUCLEUSinv_updateInterface.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0638 <span class="string">'String'</span>,num2str(data.param.sampVol));
0639 <span class="keyword">end</span>
0640
0641 <span class="comment">% Matlab need some time</span>
0641 <span class="comment">% Matlab needs some time</span>
0642 pause(0.001);
0643
0644 <span class="keyword">end</span>
Expand Down
4 changes: 2 additions & 2 deletions doc/nucleus/NUCLEUSmod/NUCLEUSmod.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0041 <span class="keyword">if</span> ~isempty(h0); close(h0); <span class="keyword">end</span>
0042
0043 <span class="comment">%% GUI 'header' info and defaults</span>
0044 myui.version = <span class="string">'0.1.5'</span>;
0045 myui.date = <span class="string">'27.03.2019'</span>;
0044 myui.version = <span class="string">'0.1.7'</span>;
0045 myui.date = <span class="string">'27.06.2019'</span>;
0046 myui.author = <span class="string">'Thomas Hiller'</span>;
0047 myui.email = <span class="string">'thomas.hiller[at]leibniz-liag.de'</span>;
0048 myui.fontsize = 10;
Expand Down
247 changes: 138 additions & 109 deletions doc/nucleus/functions/import/LoadNMRData_bamtom.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0038 <span class="comment">% load Parameter file</span>
0039 [parData] = <a href="#_sub2" class="code" title="subfunction [data] = LoadParameterFile(datapath,fname)">LoadParameterFile</a>(in.path,[in.name,<span class="string">'.par'</span>]);
0040 <span class="comment">% check if T1 or T2 data</span>
0041 <span class="keyword">if</span> strcmp(parData.measurementType,<span class="string">'CPMG_Lift'</span>)
0041 <span class="keyword">if</span> ~isempty(strfind(parData.measurementType,<span class="string">'CPMG'</span>))
0042 T1T2flag = <span class="string">'T2'</span>;
0043 <span class="keyword">else</span>
0044 T1T2flag = <span class="string">'T1'</span>;
Expand All @@ -131,116 +131,145 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0055
0056 <span class="comment">% read all 'nslices' measurements</span>
0057 nslices = parData.nSlices;
0058
0059 nmrData = cell(1,nslices);
0060 <span class="keyword">for</span> i = 1:nslices
0061 <span class="comment">% find data file</span>
0062 file = dir(fullfile(in.path,[<span class="string">'*'</span>,sprintf(<span class="string">'%03d'</span>,i),<span class="string">'.csv'</span>]));
0063
0064 <span class="comment">% read the data file</span>
0065 data = <a href="#_sub1" class="code" title="subfunction [data] = LoadDataFile(datapath,fname,flag)">LoadDataFile</a>(in.path,file.name,T1T2flag);
0066
0067 <span class="comment">% save the NMR data</span>
0068 nmrData{i}.flag = data.flag;
0069 nmrData{i}.T1IRfac = 1;
0070 nmrData{i}.time = data.time;
0071 nmrData{i}.signal = data.signal;
0072 nmrData{i}.raw = data.raw;
0073 nmrData{i}.phase = data.phase;
0074 nmrData{i}.phase_bam = data.phase_bam;
0075 clear data
0076
0077 <span class="comment">% get file statistics</span>
0078 nmrData{i}.datfile = file.name;
0079 nmrData{i}.date = file.date;
0080 nmrData{i}.datenum = file.datenum;
0081 nmrData{i}.bytes = file.bytes;
0082 <span class="keyword">end</span>
0083 <span class="keyword">end</span>
0084
0085 <span class="comment">% save data to output struct</span>
0086 out.parData = parData;
0087 out.nmrData = nmrData;
0088
0089 <span class="keyword">end</span>
0090
0091 <span class="comment">%% load NMR data file</span>
0092 <a name="_sub1" href="#_subfunctions" class="code">function [data] = LoadDataFile(datapath,fname,flag)</a>
0093
0094 d = importdata(fullfile(datapath,fname),<span class="string">'\t'</span>,3);
0095
0096 <span class="comment">% phase</span>
0097 tmpstr = d.textdata{2,1};
0098 colonstr = strfind(tmpstr,<span class="string">':'</span>);
0099 data.phase_bam = str2double(tmpstr(colonstr+1:end-4));
0100 <span class="comment">% to compare the BAM TOM phase with the NUCLEUS fit phase shift and flip</span>
0101 <span class="comment">% the phase value</span>
0102 data.phase_bam = -1*(data.phase_bam + pi);
0103
0104 <span class="comment">% standard data</span>
0105 data.flag = flag;
0106 data.time = d.data(:,1);
0107 <span class="keyword">switch</span> flag
0108 <span class="keyword">case</span> <span class="string">'T1'</span>
0109 data.signal = d.data(:,2);
0110 <span class="keyword">case</span> <span class="string">'T2'</span>
0111 data.signal = complex(d.data(:,2),d.data(:,3));
0112 [data.signal,data.phase] = <a href="rotateT2phase.html" class="code" title="function [s_rot,alpha] = rotateT2phase(s)">rotateT2phase</a>(data.signal);
0113 <span class="keyword">end</span>
0114
0115 <span class="comment">% save raw data</span>
0116 data.raw.time = data.time;
0117 data.raw.signal = data.signal;
0118
0119 <span class="keyword">end</span>
0120
0121 <span class="comment">%% load parameter file</span>
0122 <a name="_sub2" href="#_subfunctions" class="code">function [data] = LoadParameterFile(datapath,fname)</a>
0123
0124 fid = fopen(fullfile(datapath,fname));
0125 d = textscan(fid,<span class="string">'%s'</span>,<span class="string">'Delimiter'</span>,<span class="string">'\n'</span>);
0126 fclose(fid);
0127
0128 <span class="keyword">for</span> i = 1:size(d{1},1)
0129 str = char(d{1}(i));
0130 <span class="keyword">if</span> ~isempty(str) &amp;&amp; ~strcmp(str(1),<span class="string">'#'</span>)
0131 str = <a href="fixParameterString.html" class="code" title="function str = fixParameterString(str)">fixParameterString</a>(str);
0132 <span class="keyword">if</span> ~isempty(strfind(str,<span class="string">'coilName'</span>)) || ~isempty(strfind(str,<span class="string">'measurementType'</span>))
0133 streq = strfind(str,<span class="string">'='</span>);
0134 newstr = [str(1:streq(1)),<span class="string">''''</span>,strtrim(str(streq(1)+1:end)),<span class="string">''''</span>];
0135 str = newstr;
0136 <span class="keyword">end</span>
0137 eval([<span class="string">'data.'</span>,str,<span class="string">';'</span>]);
0138 <span class="keyword">end</span>
0139 <span class="keyword">end</span>
0140 data.all = d;
0141
0058 ncsvfiles = numel(dir(fullfile(in.path,<span class="string">'*.csv'</span>)));
0059
0060 <span class="keyword">if</span> nslices == ncsvfiles
0061
0062 nmrData = cell(1,nslices);
0063 <span class="keyword">for</span> i = 1:nslices
0064 <span class="comment">% find data file</span>
0065 file = dir(fullfile(in.path,[<span class="string">'*'</span>,sprintf(<span class="string">'%03d'</span>,i),<span class="string">'.csv'</span>]));
0066
0067 <span class="comment">% read the data file</span>
0068 data = <a href="#_sub1" class="code" title="subfunction [data] = LoadDataFile(datapath,fname,flag)">LoadDataFile</a>(in.path,file.name,T1T2flag);
0069
0070 <span class="comment">% save the NMR data</span>
0071 nmrData{i}.flag = data.flag;
0072 nmrData{i}.T1IRfac = 1;
0073 nmrData{i}.time = data.time;
0074 nmrData{i}.signal = data.signal;
0075 nmrData{i}.raw = data.raw;
0076 nmrData{i}.phase = data.phase;
0077 nmrData{i}.phase_bam = data.phase_bam;
0078 clear data
0079
0080 <span class="comment">% get file statistics</span>
0081 nmrData{i}.datfile = file.name;
0082 nmrData{i}.date = file.date;
0083 nmrData{i}.datenum = file.datenum;
0084 nmrData{i}.bytes = file.bytes;
0085 <span class="keyword">end</span>
0086
0087 <span class="keyword">else</span>
0088
0089 files = dir(fullfile(in.path,<span class="string">'*.csv'</span>));
0090 nmrData = cell(1,ncsvfiles);
0091 <span class="keyword">for</span> i = 1:ncsvfiles
0092 <span class="comment">% read the data file</span>
0093 data = <a href="#_sub1" class="code" title="subfunction [data] = LoadDataFile(datapath,fname,flag)">LoadDataFile</a>(in.path,files(i).name,T1T2flag);
0094
0095 <span class="comment">% save the NMR data</span>
0096 nmrData{i}.flag = data.flag;
0097 nmrData{i}.T1IRfac = 1;
0098 nmrData{i}.time = data.time;
0099 nmrData{i}.signal = data.signal;
0100 nmrData{i}.raw = data.raw;
0101 nmrData{i}.phase = data.phase;
0102 nmrData{i}.phase_bam = data.phase_bam;
0103 clear data
0104
0105 <span class="comment">% get file statistics</span>
0106 nmrData{i}.datfile = files(i).name;
0107 nmrData{i}.date = files(i).date;
0108 nmrData{i}.datenum = files(i).datenum;
0109 nmrData{i}.bytes = files(i).bytes;
0110 <span class="keyword">end</span>
0111 <span class="keyword">end</span>
0112 <span class="keyword">end</span>
0113
0114 <span class="comment">% save data to output struct</span>
0115 out.parData = parData;
0116 out.nmrData = nmrData;
0117
0118 <span class="keyword">end</span>
0119
0120 <span class="comment">%% load NMR data file</span>
0121 <a name="_sub1" href="#_subfunctions" class="code">function [data] = LoadDataFile(datapath,fname,flag)</a>
0122
0123 d = importdata(fullfile(datapath,fname),<span class="string">'\t'</span>,3);
0124
0125 <span class="comment">% phase</span>
0126 tmpstr = d.textdata{2,1};
0127 colonstr = strfind(tmpstr,<span class="string">':'</span>);
0128 data.phase_bam = str2double(tmpstr(colonstr+1:end-4));
0129 <span class="comment">% to compare the BAM TOM phase with the NUCLEUS fit phase shift and flip</span>
0130 <span class="comment">% the phase value</span>
0131 data.phase_bam = -1*(data.phase_bam + pi);
0132
0133 <span class="comment">% standard data</span>
0134 data.flag = flag;
0135 data.time = d.data(:,1);
0136 <span class="keyword">switch</span> flag
0137 <span class="keyword">case</span> <span class="string">'T1'</span>
0138 data.signal = d.data(:,2);
0139 <span class="keyword">case</span> <span class="string">'T2'</span>
0140 data.signal = complex(d.data(:,2),d.data(:,3));
0141 [data.signal,data.phase] = <a href="rotateT2phase.html" class="code" title="function [s_rot,alpha] = rotateT2phase(s)">rotateT2phase</a>(data.signal);
0142 <span class="keyword">end</span>
0143
0144 <span class="comment">%------------- END OF CODE --------------</span>
0145
0146 <span class="comment">%% License:</span>
0147 <span class="comment">% MIT License</span>
0148 <span class="comment">%</span>
0149 <span class="comment">% Copyright (c) 2019 Thomas Hiller</span>
0150 <span class="comment">%</span>
0151 <span class="comment">% Permission is hereby granted, free of charge, to any person obtaining a copy</span>
0152 <span class="comment">% of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
0153 <span class="comment">% in the Software without restriction, including without limitation the rights</span>
0154 <span class="comment">% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
0155 <span class="comment">% copies of the Software, and to permit persons to whom the Software is</span>
0156 <span class="comment">% furnished to do so, subject to the following conditions:</span>
0157 <span class="comment">%</span>
0158 <span class="comment">% The above copyright notice and this permission notice shall be included in all</span>
0159 <span class="comment">% copies or substantial portions of the Software.</span>
0160 <span class="comment">%</span>
0161 <span class="comment">% THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
0162 <span class="comment">% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
0163 <span class="comment">% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
0164 <span class="comment">% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
0165 <span class="comment">% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
0166 <span class="comment">% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
0167 <span class="comment">% SOFTWARE.</span></pre></div>
0144 <span class="comment">% save raw data</span>
0145 data.raw.time = data.time;
0146 data.raw.signal = data.signal;
0147
0148 <span class="keyword">end</span>
0149
0150 <span class="comment">%% load parameter file</span>
0151 <a name="_sub2" href="#_subfunctions" class="code">function [data] = LoadParameterFile(datapath,fname)</a>
0152
0153 fid = fopen(fullfile(datapath,fname));
0154 d = textscan(fid,<span class="string">'%s'</span>,<span class="string">'Delimiter'</span>,<span class="string">'\n'</span>);
0155 fclose(fid);
0156
0157 <span class="keyword">for</span> i = 1:size(d{1},1)
0158 str = char(d{1}(i));
0159 <span class="keyword">if</span> ~isempty(str) &amp;&amp; ~strcmp(str(1),<span class="string">'#'</span>)
0160 str = <a href="fixParameterString.html" class="code" title="function str = fixParameterString(str)">fixParameterString</a>(str);
0161 <span class="keyword">if</span> ~isempty(strfind(str,<span class="string">'coilName'</span>)) || ~isempty(strfind(str,<span class="string">'measurementType'</span>))
0162 streq = strfind(str,<span class="string">'='</span>);
0163 newstr = [str(1:streq(1)),<span class="string">''''</span>,strtrim(str(streq(1)+1:end)),<span class="string">''''</span>];
0164 str = newstr;
0165 <span class="keyword">end</span>
0166 eval([<span class="string">'data.'</span>,str,<span class="string">';'</span>]);
0167 <span class="keyword">end</span>
0168 <span class="keyword">end</span>
0169 data.all = d;
0170
0171 <span class="keyword">end</span>
0172
0173 <span class="comment">%------------- END OF CODE --------------</span>
0174
0175 <span class="comment">%% License:</span>
0176 <span class="comment">% MIT License</span>
0177 <span class="comment">%</span>
0178 <span class="comment">% Copyright (c) 2019 Thomas Hiller</span>
0179 <span class="comment">%</span>
0180 <span class="comment">% Permission is hereby granted, free of charge, to any person obtaining a copy</span>
0181 <span class="comment">% of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
0182 <span class="comment">% in the Software without restriction, including without limitation the rights</span>
0183 <span class="comment">% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
0184 <span class="comment">% copies of the Software, and to permit persons to whom the Software is</span>
0185 <span class="comment">% furnished to do so, subject to the following conditions:</span>
0186 <span class="comment">%</span>
0187 <span class="comment">% The above copyright notice and this permission notice shall be included in all</span>
0188 <span class="comment">% copies or substantial portions of the Software.</span>
0189 <span class="comment">%</span>
0190 <span class="comment">% THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
0191 <span class="comment">% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
0192 <span class="comment">% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
0193 <span class="comment">% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
0194 <span class="comment">% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
0195 <span class="comment">% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE</span>
0196 <span class="comment">% SOFTWARE.</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2005</address>
</body>
</html>
Loading

0 comments on commit 7ab6650

Please sign in to comment.