Skip to content

Commit

Permalink
5.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JanAxelsson committed Oct 2, 2020
2 parents f27abfd + 6055e61 commit 4970dcd
Show file tree
Hide file tree
Showing 23 changed files with 412 additions and 98 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Ignore Mac DS_Store files
.DS_Store

# Ignore file with private information
imlook4d-zip-and-release-to-google-drive
release to google drive/client_secrets.json
release to google drive/mycreds.txt

# Ignore MATLAB backup files
*~

Expand Down
4 changes: 2 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ ERRORS
[ ] Help on Buttons TACT, Clear. Help on drop down "Clear ROI"
[ ] Command Button('TACT') does not work. Button('Clear') works.
[ ] Help now goes all the way up to "Image View Port". Rewrite so it goes only to parent
[ ] Help on Record button missing

[ ] Help on Record button missing



Expand Down
Binary file removed imlook4d/DOCS/Models.odt
Binary file not shown.
1 change: 1 addition & 0 deletions imlook4d/DOCS/Models_exported_to_html/.~lock.Models.html#
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
,jan,Linux,25.06.2020 11:51,file:///mnt/Data/home/jan/.config/libreoffice/4;
205 changes: 128 additions & 77 deletions imlook4d/DOCS/Models_exported_to_html/Models.html

Large diffs are not rendered by default.

Binary file modified imlook4d/DOCS/Models_exported_to_html/Models.odt
Binary file not shown.
13 changes: 13 additions & 0 deletions imlook4d/HELP/Export times to sif.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1>Export times to sif</h1>
<HR></HR>
<!------------------->

<P>
Nifti files do not carry information about time, which is necessary in some processing of dynamic scans.
This script exports time information from a DICOM file to a .sif file.
</P>


<P>
Nifti files can obtain time information by importing it from a .sif file. See "Import times from sif"
</P>
17 changes: 17 additions & 0 deletions imlook4d/HELP/Import times from sif.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<h1>Import times from sif</h1>
<HR></HR>
<!------------------->

<P>
Nifti files do not carry information about time, which is necessary in some processing of dynamic scans.
This script import time information from a .sif file.
</P>




<P>
.sif files can be created from the original DICOM files (which carry time information), by "SCRIPTS/Matrix/Export times to sif"

</P>

15 changes: 15 additions & 0 deletions imlook4d/HELP/Open.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<LI> <B><a href="javascript:;" onclick="document.location.hash='ROI';">ROI file + image </a> </B> (.roi)
<LI> <B><a href="javascript:;" onclick="document.location.hash='DICOM';">DICOM</a> </B>
<LI> <B><a href="javascript:;" onclick="document.location.hash='Nifti';">Nifti</a> </B> (.nii, .hdr, .img)
<LI> <B><a href="javascript:;" onclick="document.location.hash='Nifti-pmod';">Nifti PMOD</a> </B> (.nii)

<LI> <B><a href="javascript:;" onclick="document.location.hash='ECAT';">Siemens/CTI ECAT 7</a></B> (.v)
<LI> <B><a href="javascript:;" onclick="document.location.hash='Analyze';">Analyze</a> </B> (.hdr, .img)
Expand Down Expand Up @@ -110,6 +111,20 @@
</P>


<a href="javascript:;" onclick="document.location.hash='top';">[top]</a>

<h2><a id="Nifti-pmod">Nifti file opening (PMOD)</a></h2>
<!------------------------>

<P>
Opens .nii files (one binary file), converted from Dicom using PMOD. This is read-only.
</P>

<P>
Time information from 4D PET is imported using the PMOD Nifti extension format.
</P>


<a href="javascript:;" onclick="document.location.hash='top';">[top]</a>
<h2><a id="ECAT">Siemens ECAT file opening</a></h2>
<!------------------------>
Expand Down
6 changes: 1 addition & 5 deletions imlook4d/HELP/SPM Tissue probability map ROIs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<HR></HR>
<!------------------->
<P>
Finds the following region-of-interests (ROIs) from the tissue-probability maps for this file:
Finds the following region-of-interests (ROIs), calculated from the tissue-probability maps for this file:
<ol>
<li> Gray Matter
<li> White Matter
Expand All @@ -14,10 +14,6 @@
</ol>
</P>

<P>
Nifti cannot store ROI names. ROI names may be loaded using the script "ROI/ROI naming from file", where "TPM_Based_ROIs.txt" should be selected.
</P>

<P>

This script uses files named c1xxx to c5xxx that are created prior to this script, when the user executed "Apply atlas".
Expand Down
6 changes: 5 additions & 1 deletion imlook4d/HELP/align.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@
</P>

<P>
The alignment reads a 4D nifti file and uses the spm spatial realignment functions.
The alignment reads a 4D nifti file and uses the spm spatial realignment functions optimized for PET.
</P>

<P>
For PET, often the first frames are meaningless being only noise. This may cause the realignment to fail. Therefore, you will in a dialog need to
define the first frame to use for realignment.
</P>
<P>
</P>
11 changes: 11 additions & 0 deletions imlook4d/HELP/transparancyEdit.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<h1>Transparancy Edit</h1>
<HR></HR>
<!------------------->
<P>
This value between 0-100 % sets the weight of the frontmost image. A lower value shows more of the underlying image.
</P>


<P>
This setting is shown only if overlay images are shown.
</P>
6 changes: 5 additions & 1 deletion imlook4d/SCRIPTS/Change/Duplicate.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,17 @@
set( HmatchNew(i), 'String', get( HmatchOld(i), 'String') );
end

% Copy status of transparancyPanel
newHandles.transparancyPanel.Visible = imlook4d_current_handles.transparancyPanel.Visible;
newHandles.transparancyText.Visible = imlook4d_current_handles.transparancyText.Visible;
newHandles.transparancyEdit.Visible = imlook4d_current_handles.transparancyEdit.Visible;

% Copy record-button status
tag = 'record_toolbar_button';
HmatchOld = findobj(imlook4d_current_handle,'Tag',tag);
HmatchNew = findobj(newHandle,'Tag',tag);
set( HmatchNew(1), 'State', get( HmatchOld(1), 'State') );


%
% FINALIZE
%
Expand Down
51 changes: 51 additions & 0 deletions imlook4d/SCRIPTS/Matrix/Export_times_to_sif.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
StoreVariables
Export



timeScale = imlook4d_time';
duration = imlook4d_duration';
activity = zeros( size(imlook4d_time))';


[file,path] = uiputfile( {...
'*.sif', 'Turku (blood/weight) (*.sif)' ...
}, ...
'Export times to sif file', 'TACT.sif');

[pathstr,name,ext] = fileparts(file); % To get extension
fullPath=[path file];

%
% Copied from SaveTact.m
%

% Simplified sif file, from one ROI


% Header info
scan_start_time = 'xx/xx/xxxx xx:xx:xx'
number_of_frames = length(imlook4d_time);
number_of_columns = 2 + size(activity,2) ;
SIF_version = '1';
study_ID = 'xxxx';
isotope = 'X-XX';

if ( size(activity,2) == 1 )
activity = [ activity activity ]; % Sif seems to require 4 columns (minimum)
number_of_columns = 2 + size(activity,2) ;
end

tactHeader=[sprintf(['%s' '\t'], scan_start_time, num2str(number_of_frames), num2str(number_of_columns), SIF_version, study_ID, isotope) ];
tactHeader=tactHeader(1:end-1); % Remove last TAB

unitFactor = 1; % Do nothing
try

save_cellarray( num2cell([ timeScale (timeScale+duration) unitFactor*double(activity) ]), fullPath, tactHeader );
catch
%disp('You selected not to save TACT curve');
end

Import
%ClearVariables
2 changes: 2 additions & 0 deletions imlook4d/SCRIPTS/Matrix/sort.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ Exchange_Slices_to_Frames.m
---
#Additional_:
Import_times_from_sif.m
Export_times_to_sif.m
---
Matrix_to_ROI.m
ScreePlot.m
30 changes: 27 additions & 3 deletions imlook4d/SCRIPTS/SPM/SPM_Tissue_probability_map_ROIs.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@
if ~verifySpmExists()
return
end

Export;

currentFile = imlook4d_current_handles.image.file;

if (startsWith(currentFile,'mni') )
warndlg({'Tissue probability map ROIs must be calculated from native-space image'})
return
end



StartScript; % Start a script and open a new instance of imlook4d to play with

% Data fields that can be modified in your own code:
Expand All @@ -32,10 +44,15 @@

%% Open c1-c5

currentFile = imlook4d_current_handles.image.file;
cFile = [ 'c1' currentFile];
oldDir = pwd();
cd( imlook4d_current_handles.image.folder);

% Open c1
cFile = [ 'c1' currentFile];
if ~isfile( cFile ) % Correct file name, may have used 'mean' for a dynamic scan
cFile = strrep( cFile, 'c1', 'c1mean')
end

V = spm_vol(cFile);
A = spm_read_vols(V); % Individual's c1... file

Expand All @@ -49,6 +66,11 @@
% Open c2-c5
for i = 2:5
cFile = [ 'c' num2str(i) currentFile];
if ~isfile(cFile) % Correct file name, may have used 'mean' for a dynamic scan
was = ['c' num2str(i)]; % 'c2'
is = [was 'mean']; % 'c2mean'
cFile = strrep( cFile, was, is);
end
V = spm_vol(cFile);
A = spm_read_vols(V); % Individual's c1... file
M(:,:,:,i) = A;
Expand Down Expand Up @@ -76,11 +98,13 @@
V = spm_write_vol(V, NewROIs);

LoadROI(newFile);

ROI_naming_from_file( which( 'TPM_based_ROIs.txt'));
copyfile( which( 'TPM_based_ROIs.txt'), pwd() ); % is in target directory (cd at top of file)

% --------------------------------------------------
% END OF OWN CODE
% --------------------------------------------------
cd(oldDir);

%EndScript; % Import your changes into new instance and clean up your variables

Expand Down
21 changes: 18 additions & 3 deletions imlook4d/SCRIPTS/SPM/align.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,34 @@
% START OWN CODE:
% --------------------------------------------------


% First frame dialog
prompt={'First frame (noisy data does not align)'};
[answer, imlook4d_current_handles] = ModelDialog( imlook4d_current_handles, ...
'align', ...
prompt, ...
{ '1' } ...
);

firstFrame = str2num(answer{1});

% Setup realignment

spm('defaults','pet');
spm_jobman('initcfg');

matlabbatch{1}.spm.util.exp_frames.files = { [path ',1']};
%matlabbatch{1}.spm.util.exp_frames.files = {'/Users/jan/Desktop/IMAGES/DAD-tests/D34/native/Sharp.nii,1'};
matlabbatch{1}.spm.util.exp_frames.frames = [1 : numberOfFrames];
%matlabbatch{1}.spm.util.exp_frames.frames = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18];


matlabbatch{1}.spm.util.exp_frames.frames = [firstFrame : numberOfFrames];
disp( ['Aligning frames = ' num2str(firstFrame) ' - ' num2str(numberOfFrames ) ]);

matlabbatch{2}.spm.spatial.realign.estwrite.data{1}(1) = cfg_dep('Expand image frames: Expanded filename list.', substruct('.','val', '{}',{1}, '.','val', '{}',{1}, '.','val', '{}',{1}), substruct('.','files'));
matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.quality = 0.9;
matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.sep = 4;
matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.fwhm = 5;
matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.rtm = 1;
matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.rtm = 1; % Register to mean
matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.interp = 2;
matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.wrap = [0 0 0];
matlabbatch{2}.spm.spatial.realign.estwrite.eoptions.weight = '';
Expand Down
6 changes: 6 additions & 0 deletions imlook4d/SCRIPTS/SPM/atlas_GM.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@

GM_ROI_file = [ folder filesep 'c1' FILE ext];

% Dynamic files has been using mean file, fix name
if ~isfile(GM_ROI_file)
disp('assuming mean file')
GM_ROI_file = strrep( GM_ROI_file, 'c1', 'c1mean')
end

try
nii = load_nii(GM_ROI_file);
openingMode='load_nii';
Expand Down
6 changes: 6 additions & 0 deletions imlook4d/SCRIPTS/View/Background_image__add.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,10 @@
end
%end

% Show transparancy setting
imlook4d_current_handles.transparancyEdit.Visible = 'on';
imlook4d_current_handles.transparancyText.Visible = 'on';
imlook4d_current_handles.transparancyPanel.Visible = 'on';

% Finish
ClearVariables
8 changes: 8 additions & 0 deletions imlook4d/SCRIPTS/View/Background_image__remove.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
imlook4d_current_handles.image.backgroundImageHandle = [];
imlook4d_current_handles.image.CachedImage2 = [];
Import


% Show transparancy setting
imlook4d_current_handles.transparancyEdit.Visible = 'off';
imlook4d_current_handles.transparancyText.Visible = 'off';
imlook4d_current_handles.transparancyPanel.Visible = 'off';

% Finish
ClearVariables

clear imlook4d_current_handles.image.backgroundImageHandle
3 changes: 2 additions & 1 deletion imlook4d/external functions/loop/loop.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

disp('=================================');
disp(['DATA SOURCE (for loop)' ]);
disp([' Time = ' char(datetime()) ]);
disp([' Function = ' functionName ]);
disp([' Excel file = ' xlsFileList ]);
disp([' Excel sheet = ' sheet ]);
Expand Down Expand Up @@ -165,7 +166,7 @@
' NOTE : Found ' num2str(emptyColumns) ' empty fields' ]);

% Create emtpy table row
T2 = cell2table( num2cell(nan(1,17)) );
T2 = cell2table( num2cell(nan(1,size(T,2))) );
T2.Properties.VariableNames = T.Properties.VariableNames;

for i = 1 : size(T,2)
Expand Down
Binary file modified imlook4d/imlook4d.fig
Binary file not shown.
Loading

0 comments on commit 4970dcd

Please sign in to comment.