diff --git a/demos/2D/demo2D00/demo2D00.m b/demos/2D/demo2D00/demo2D00.m new file mode 100644 index 0000000..280cb73 --- /dev/null +++ b/demos/2D/demo2D00/demo2D00.m @@ -0,0 +1,76 @@ +function answer = demo2D00( option ) +% demo2D00 +% +% Synthesize one 2D image with nuclear, cell shape, and vesicular channels +% from all vesicular object models (nucleoli, lysosomes, endosomes, and +% mitochondria) without convolution. The model was trained from the Murphy +% Lab 2D HeLa dataset. +% +% Input +% ----- +% * a list of valid CellOrganizer model files +% +% Output +% ------ +% * one TIFF file with six slices (nuclear, cell shape, nucleolar, +% lysosomal, endosomal, and mitochondrial channels) + +% Ivan E. Cao-Berg (icaoberg@cmu.edu) +% +% Copyright (C) 2012-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo2D00' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.prefix = 'imgs'; +options.compression = 'lzw'; +options.debug = false; +options.temporary_results = [ pwd filesep 'temporary_results' ]; +options.verbose = false; +options.synthesis = 'all'; +options.output.tifimages = false; +options.output.OMETIFF = true; +options.numberOfSynthesizedImages = 1; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( {'../../../models/2D/nucleolus.mat', ... + '../../../models/2D/lysosome.mat', ... + '../../../models/2D/endosome.mat', ... + '../../../models/2D/mitochondrion.mat'}, options ); +end%demo2D00 diff --git a/demos/2D/demo2D01/demo2D01.m b/demos/2D/demo2D01/demo2D01.m new file mode 100755 index 0000000..e1a21cc --- /dev/null +++ b/demos/2D/demo2D01/demo2D01.m @@ -0,0 +1,93 @@ +function answer = demo2D01( options ) +% demo2D01 +% +% Train a 2D generative model of the nucleus, cell shape, and lysosomes using +% all LAMP2 images in the Murphy Lab 2D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * a directory of raw or synthetic lysosome images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Ivan E. Cao-Berg (icaoberg@cmu.edu) +% +% Copyright (C) 2013-2020 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo2D01' ); +disp( 'The estimated running time is 7-10 minutes. Please wait.' ); + +options.verbose = true; +options.debug = true; +options.save_segmentations = true; +options.display = false; +options.skip_preprocessing = true; +options.model.name = 'demo2D01'; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'all' ))); +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.type = 'medial_axis'; +options.cell.class = 'cell_membrane'; +options.cell.type = 'ratio'; +options.protein.class = 'vesicle'; +options.save_segmentations = true; +options.protein.type = 'gmm'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +dna = {}; cellm = {}; protein = {}; options.masks = {}; options.labels = {}; + +directory = '../../../images/HeLa/2D/LAM'; +for i=1:1:25 + dna{length(dna)+1} = [ directory filesep 'orgdna' filesep 'cell' num2str(i) '.tif' ]; + cellm{length(cellm)+1} = [ directory filesep 'orgcell' filesep 'cell' num2str(i) '.tif' ]; + protein{length(protein)+1} = [ directory filesep 'orgprot' filesep 'cell' num2str(i) '.tif' ]; + options.labels{length(options.labels)+1} = 'LAMP2'; + options.masks{length(options.masks)+1} = [ directory filesep 'crop' filesep 'cell' num2str(i) '.tif' ]; +end + +options.temporary_results = [ pwd filesep 'temporary_results' ]; +options.model.resolution = [ 0.049, 0.049 ]; +options.model.filename = 'lamp2.xml'; +options.model.id = 'lamp2'; +options.model.name = 'lamp2'; + +%documentation +options.documentation.description = 'This model has been trained using demo2D01 from CellOrganizer'; + +answer = img2slml( '2D', dna, cellm, protein, options ); diff --git a/demos/2D/demo2D02/demo2D02.m b/demos/2D/demo2D02/demo2D02.m new file mode 100755 index 0000000..004f04b --- /dev/null +++ b/demos/2D/demo2D02/demo2D02.m @@ -0,0 +1,82 @@ +function answer = demo2D02() +% demo2D02 +% +% Synthesize one 2D image with nuclear, cell shape, and lysosomal channels +% from LAMP2 model trained in demo2D01 without convolution. +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * one TIFF file with three slices (nuclear, cell shape, and lysosomal +% channels) + +% Ivan E. Cao-Berg (icaoberg@cmu.edu) +% +% Copyright (C) 2013-2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo2D02' ); +disp( 'The estimated running time is 1 minute. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%modify the next line to generate more images +options.numberOfSynthesizedImages = 1; + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.debug = false; +options.verbose = true; +options.display = false; + +filename = '../demo2D01/lamp2.mat'; +if ~exist( filename ) + warning( [ 'File ' filename ' not found.' ] ); + disp('Using alternative model present in this distribution.'); + filename = '../../../models/2D/endosome.mat'; +end + +options.output.tifimages = false; +options.output.OMETIFF = true; + +slml2img( {filename}, options ); +answer = true; +end%demo2D02 diff --git a/demos/2D/demo2D03/demo2D03.m b/demos/2D/demo2D03/demo2D03.m new file mode 100755 index 0000000..bcf661a --- /dev/null +++ b/demos/2D/demo2D03/demo2D03.m @@ -0,0 +1,85 @@ +function answer = demo2D03(options) +% demo2D03 +% +% Train 2D generative model of the nucleus and cell shape using +% all LAMP2 images in the Murphy Lab 2D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Ivan E. Cao-Berg (icaoberg@cmu.edu) +% +% Copyright (C) 2015-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo2D03' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 9 minutes. Please wait.' ); + +options.verbose = true; +options.debug = true; +options.display = false; +options.model.name = 'demo2D03'; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.type = 'medial_axis'; +options.cell.class = 'cell_membrane'; +options.cell.type = 'ratio'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% the following list of parameters are adapted to the LAMP2 image +% collection, modify these according to your needs +directory = '../../../images/HeLa/2D/LAM/'; +dna = {}; cellm = {}; protein = {}; options.masks = {}; +for i=1:1:25 + dna{length(dna)+1} = [ directory filesep 'orgdna' filesep 'cell' num2str(i) '.tif' ]; + cellm{length(cellm)+1} = [ directory filesep 'orgcell' filesep 'cell' num2str(i) '.tif' ]; + options.masks{length(options.masks)+1} = [ directory filesep 'crop' filesep 'cell' num2str(i) '.tif' ]; +end + +options.model.resolution = [ 0.049, 0.049 ]; +options.model.filename = 'lamp2.xml'; +options.model.id = 'lamp2'; + +%documentation +options.documentation.description = 'This model has been trained using demo2D0333 from CellOrganizer'; + +answer = img2slml( '2D', dna, cellm, protein, options ); diff --git a/demos/2D/demo2D04/demo2D04.m b/demos/2D/demo2D04/demo2D04.m new file mode 100644 index 0000000..47c62d7 --- /dev/null +++ b/demos/2D/demo2D04/demo2D04.m @@ -0,0 +1,107 @@ +function answer = demo2D04(options) +% demo2D04 +% +% Train 2D generative diffeomorphic nuclear and cell shape model and a +% lysosomal model using 10 LAMP2 images in the Murphy Lab 2D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * a directory of raw or synthetic lysosome images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2013-2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo2D04' ); +disp( 'The estimated running time is 3 minutes. Please wait.' ); + +options.verbose = true; +options.debug = true; +options.display = false; +options.model.name = 'demo2D04'; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.nucleus.id = uuidgen(); +options.cell.id = uuidgen(); +options.nucleus.class = 'framework'; +options.nucleus.type = 'diffeomorphic'; +options.cell.class = 'framework'; +options.cell.type = 'diffeomorphic'; +options.protein.class = 'vesicle'; +options.protein.type = 'gmm'; +options.model.diffeomorphic.distance_computing_method = 'faster'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% the following list of parameters are adapted to the LAMP2 image +% collection, modify these according to your needs + +dna = {}; cellm = {}; protein = {}; options.masks = {}; options.labels = {}; +directory = '../../../images/HeLa/2D/LAM/'; +for i=1:1:10 + dna{length(dna)+1} = [ directory filesep 'orgdna' filesep 'cell' num2str(i) '.tif' ]; + cellm{length(cellm)+1} = [ directory filesep 'orgcell' filesep 'cell' num2str(i) '.tif' ]; + protein{length(protein)+1} = [ directory filesep 'orgprot' filesep 'cell' num2str(i) '.tif' ]; + options.labels{length(options.labels)+1} = 'LAMP2'; + options.masks{length(options.masks)+1} = [ directory filesep 'crop' filesep 'cell' num2str(i) '.tif' ]; +end + +options.model.resolution = [ 0.049, 0.049 ]; +options.model.filename = 'lamp2.xml'; +options.model.id = 'lamp2'; +options.model.name = 'lamp2'; + +%set nuclei and cell model name +options.nucleus.name = 'LAMP2'; +options.cell.model = 'LAMP2'; + +%set the dimensionality of the model +dimensionality = '2D'; + +%documentation +options.documentation.description = 'This model has been trained using demo2D04 from CellOrganizer'; +options.downsampling = [5,5]; + +%set alignment method +options.model.diffeomorphic.com_align = 'nuc'; + +%train the model +answer = img2slml( dimensionality, dna, cellm, protein, options ); +end diff --git a/demos/2D/demo2D05/demo2D05.m b/demos/2D/demo2D05/demo2D05.m new file mode 100644 index 0000000..dc6d53b --- /dev/null +++ b/demos/2D/demo2D05/demo2D05.m @@ -0,0 +1,107 @@ +function answer = demo2D05(options) +% demo2D05 +% +% Train 2D generative pca nuclear and cell shape model using the Murphy Lab 2D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo2D05' ); +disp( 'The estimated running time is 1 minutes. Please wait...' ); +options.verbose = true; +options.debug = false; +options.display = false; +options.save_segmentations = true; + +options.model.name = 'demo2D05'; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.nucleus.id = uuidgen(); +options.nucleus.class = 'framework'; +options.nucleus.type = 'pca'; +options.cell.id = uuidgen(); +options.cell.class = 'framework'; +options.cell.type = 'pca'; + +% latent dimension for the model +options.model.pca.latent_dim = 15; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +dna = {}; cellm = {}; protein = {}; options.masks = {}; options.labels = {}; + +directory = '../../../images/HeLa/2D/LAM'; +for i=1:1:25 + dna{length(dna)+1} = [ directory filesep 'orgdna' filesep 'cell' num2str(i) '.tif' ]; + cellm{length(cellm)+1} = [ directory filesep 'orgcell' filesep 'cell' num2str(i) '.tif' ]; + protein{length(protein)+1} = [ directory filesep 'orgprot' filesep 'cell' num2str(i) '.tif' ]; + options.labels{length(options.labels)+1} = 'LAMP2'; + options.masks{length(options.masks)+1} = [ directory filesep 'crop' filesep 'cell' num2str(i) '.tif' ]; +end + +directory = '../../../images/HeLa/2D/Nuc'; +for i=1:1:25 + dna{length(dna)+1} = [ directory filesep 'orgdna' filesep 'cell' num2str(i) '.tif' ]; + cellm{length(cellm)+1} = [ directory filesep 'orgcell' filesep 'cell' num2str(i) '.tif' ]; + protein{length(protein)+1} = [ directory filesep 'orgprot' filesep 'cell' num2str(i) '.tif' ]; + options.labels{length(options.labels)+1} = 'Nucleoli'; + options.masks{length(options.masks)+1} = [ directory filesep 'crop' filesep 'cell' num2str(i) '.tif' ]; +end + +options.model.resolution = [ 0.049, 0.049 ]; +options.model.filename = 'model.xml'; +options.model.id = uuidgen(); +options.model.name = '2D HeLa LAMP2+Nuc'; +%set nuclei and cell model name +options.nucleus.name = 'LAMP2+Nuc'; +options.cell.model = 'LAMP2+Nuc'; +%set the dimensionality of the model +dimensionality = '2D'; +%documentation +options.documentation.description = 'This model has been trained using demo2D05 from CellOrganizer'; +%set model type +options.train.flag = 'framework'; + +tic; answer = img2slml( dimensionality, dna, cellm, [], options ); toc, +end diff --git a/demos/2D/demo2D06/demo2D06.m b/demos/2D/demo2D06/demo2D06.m new file mode 100644 index 0000000..4073a2f --- /dev/null +++ b/demos/2D/demo2D06/demo2D06.m @@ -0,0 +1,74 @@ +function answer = demo2D06() +% demo2D06 +% +% Reconstruct one 2D image with nuclear, cell shape for PCA model +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * one TIFF file with three slices (nuclear, cell shape, and lysosomal +% channels) + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end +disp( 'demo2D06' ); +disp( 'The estimated running time is 1 minute. Please wait.' ); +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%modify the next line to generate more images +options.numberOfSynthesizedImages = 1; +options.model.pca.pca_synthesis_method = 'reconstruction'; +options.model.pca.imageSize = [1024, 1024]; +options.output.OMETIFF = true; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; + +filename = '../demo2D05/model.mat'; +if ~exist( filename ) + warning( [ 'File ' filename ' not found.' ] ); + answer = false; + return +end + +answer = slml2img( {filename}, options ); +end diff --git a/demos/2D/demo2D07/demo2D07.m b/demos/2D/demo2D07/demo2D07.m new file mode 100644 index 0000000..b7dace9 --- /dev/null +++ b/demos/2D/demo2D07/demo2D07.m @@ -0,0 +1,78 @@ +function answer = demo2D07() +% demo2D07 +% +% Synthesize one 2D image with nuclear, cell shape with PCA model +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * one TIFF file with three slices (nuclear, cell shape, and lysosomal +% channels) + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo2D07' ); +disp( 'The estimated running time is 1 minute. Please wait.' ); +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%modify the next line to generate more images +options.numberOfSynthesizedImages = 1; +options.model.pca.pca_synthesis_method = 'random_sampling'; +options.model.pca.imageSize = [1024, 1024]; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.debug = false; +options.verbose = true; +options.display = false; +options.output.OMETIFF = true; +filename = '../demo2D05/model.mat'; + +if ~exist( filename ) + warning( [ 'File ' filename ' not found.' ] ); + answer = false; + return +end + +answer = slml2img( {filename}, options ); +end diff --git a/demos/2D/demo2D08/demo2D08.m b/demos/2D/demo2D08/demo2D08.m new file mode 100644 index 0000000..bdcec41 --- /dev/null +++ b/demos/2D/demo2D08/demo2D08.m @@ -0,0 +1,98 @@ +function answer = demo2D08(options) +% demo2D08 +% +% Train 2D generative pca nuclear and cell shape model using the Murphy Lab +% 2D HeLa dataset and makes a shape space plot +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file +% * a shape space plot + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end +disp( 'demo2D08' ); +disp( 'The estimated running time is 1 minutes. Please wait...' ); +options.verbose = true; +options.debug = false; +options.display = false; +options.model.name = 'demo2D08'; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.nucleus.class = 'framework'; +options.nucleus.type = 'pca'; +options.cell.class = 'framework'; +options.cell.type = 'pca'; + +% latent dimension for the model +options.model.pca.latent_dim = 15; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% the following list of parameters are adapted to the LAMP2 image +% collection, modify these according to your needs +directory = '../../../images/HeLa/2D/LAM/'; +dna = [ directory filesep 'orgdna' filesep 'cell*.tif' ]; +cellm = [ directory filesep 'orgcell' filesep 'cell*.tif' ]; +options.masks = [ directory filesep 'crop' filesep 'cell*.tif' ]; + +options.model.resolution = [ 0.049, 0.049 ]; +options.model.filename = 'lamp2.xml'; +options.model.id = 'lamp2'; +options.model.name = 'lamp2'; +%set nuclei and cell model name +options.nucleus.name = 'LAMP2'; +options.cell.model = 'LAMP2'; +%set the dimensionality of the model +dimensionality = '2D'; +%documentation +options.documentation.description = 'This model has been trained using demo2D08 from CellOrganizer'; +%set model type +options.train.flag = 'framework'; + +tic; answer = img2slml( dimensionality, dna, cellm, [], options ); toc, + +if exist( [pwd filesep 'lamp2.mat'] ) + f = figure('visible','off'); + load( [pwd filesep 'lamp2.mat'] ); + showPCAShapeSpaceFigure(model); + saveas( f, 'show_shape_space.png', 'png' ); +end +end diff --git a/demos/2D/demo2D09/demo2D09.m b/demos/2D/demo2D09/demo2D09.m new file mode 100644 index 0000000..d755c5a --- /dev/null +++ b/demos/2D/demo2D09/demo2D09.m @@ -0,0 +1,89 @@ +function answer = demo2D09( options ) +% demo2D09 +% +% Train 2D generative pca nuclear and cell shape model using the Murphy Lab +% 2D HeLa dataset and makes a shape space plot +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file +% * a report + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo2D09' ); +options.verbose = true; +options.debug = false; +options.display = false; +options.model.name = 'demo2D09'; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.nucleus.class = 'framework'; +options.nucleus.type = 'pca'; +options.cell.class = 'framework'; +options.cell.type = 'pca'; + +% latent dimension for the model +options.model.pca.latent_dim = 15; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% the following list of parameters are adapted to the LAMP2 image +% collection, modify these according to your needs +directory = '../../../images/HeLa/2D/LAM/'; +dna = [ directory filesep 'orgdna' filesep 'cell*.tif' ]; +cellm = [ directory filesep 'orgcell' filesep 'cell*.tif' ]; +options.masks = [ directory filesep 'crop' filesep 'cell*.tif' ]; + +options.model.resolution = [ 0.049, 0.049 ]; +options.model.filename = 'lamp2.xml'; +options.model.id = 'lamp2'; +options.model.name = 'lamp2'; +%set nuclei and cell model name +options.nucleus.name = 'LAMP2'; +options.cell.model = 'LAMP2'; +%set the dimensionality of the model +dimensionality = '2D'; +%documentation +options.documentation.description = 'This model has been trained using demo2D09 from CellOrganizer'; + +answer = img2slml( dimensionality, dna, cellm, [], options ); +end diff --git a/demos/3D/demo3D00/demo3D00.m b/demos/3D/demo3D00/demo3D00.m new file mode 100755 index 0000000..d3335cd --- /dev/null +++ b/demos/3D/demo3D00/demo3D00.m @@ -0,0 +1,80 @@ +function answer = demo3D00() +% demo3D00 +% +% Synthesize one 3D image with nuclear, cell shape, and nucleolar channels +% from nucleolar model with sampling method set to render nucleoli as +% ellipsoids without convolution. The model was trained from the Murphy Lab +% 3D HeLa dataset. +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * three TIFF files (nuclear, cell shape, and nucleolar channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D00' ); +disp( 'The estimated running time is 1 minute. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.sampling.method = 'disc'; +options.microscope = 'none'; +options.debug = false; +options.verbose = true; +options.display = false; +options.output.OMETIFF = true; +options.output.tifimages = true; +options.temporary_results = [ pwd filesep 'temporary_results' ]; +options.overwrite_synthetic_instances = false; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/nuc.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); +end%demo3D00 diff --git a/demos/3D/demo3D01/demo3D01.m b/demos/3D/demo3D01/demo3D01.m new file mode 100644 index 0000000..abed4ac --- /dev/null +++ b/demos/3D/demo3D01/demo3D01.m @@ -0,0 +1,82 @@ +function answer = demo3D01() +% demo3D01 +% +% Synthesize one 3D image with nuclear, cell shape, and vesicular channels +% from all vesicular object models (lysosomes, mitochondria, nucleoli, and +% endosomes) with sampling method set to render vesicular objects as +% ellipsoids without convolution. The model was trained from the Murphy Lab +% 3D HeLa dataset. +% +% Input +% ----- +% * a list of valid CellOrganizer model files +% +% Output +% ------ +% * six TIFF files (nuclear, cell shape, lysosomal, mitochondrial, +% nucleolar, and endosomal channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D01' ); +disp( 'The estimated running time is 18 minutes. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.sampling.method = 'disc'; +options.debug = false; +options.verbose = true; +options.display = false; +options.numberOfGaussianObjects = 25; +options.output.tifimages = false; +options.output.OMETIFF = true; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/nuc.mat', ... + '../../../models/3D/lamp2.mat', ... + '../../../models/3D/tfr.mat', ... + '../../../models/3D/mit.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D02/demo3D02.m b/demos/3D/demo3D02/demo3D02.m new file mode 100755 index 0000000..48819d3 --- /dev/null +++ b/demos/3D/demo3D02/demo3D02.m @@ -0,0 +1,80 @@ +function answer = demo3D02() +% demo3D02 +% +% Generate surface plot of image synthesized by demo3D00. +% +% Input +% ----- +% * three TIFF files (nuclear, cell shape, and nucleolar channels) +% from demo3D00 directory +% +% Output +% ------ +% * a surface plot of the synthetic image + +% Robert F. Murphy +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D02' ); +disp( 'The estimated running time is 2 minutes. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +tiff_directory = '../demo3D00/img/cell1'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +if ~exist( tiff_directory ) + warning(['Directory ' tiff_directory ' not found. Run demo first.']); + return +end + +try + colors = {'blue', 'green' 'red'}; + viewangles = [20,-30]; + + %transparency + alphaval = 0.1; + syn2surfaceplot( tiff_directory, colors, viewangles, alphaval ); + saveas(gcf,'output.png'); + answer = true; +catch + warning( 'Unable to make surface plot.' ); +end diff --git a/demos/3D/demo3D03/demo3D03.m b/demos/3D/demo3D03/demo3D03.m new file mode 100755 index 0000000..a41b144 --- /dev/null +++ b/demos/3D/demo3D03/demo3D03.m @@ -0,0 +1,84 @@ +function answer = demo3D03() +% demo3D03 +% +% Synthesize one 3D image with nuclear, cell shape, and vesicular channels +% from all vesicular object models (nucleoli, lysosomes, endosomes, and +% mitochondria) with sampling method set to sample vesicular objects from +% Gaussians at density 75 without convolution. The model was trained from +% the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a list of valid CellOrganizer model files +% +% Output +% ------ +% * six TIFF files (nuclear, cell shape, nucleolar, lysosomal, endosomal, +% and mitochondrial channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D03' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 11 minutes. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'sampled'; +options.sampling.density = 75; +options.numberOfGaussianObjects = 25; +options.verbose = true; +options.debug = false; +options.output.OMETIFF = false; +options.output.tifimages = true; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/nuc.mat', ... + '../../../models/3D/lamp2.mat', ... + '../../../models/3D/tfr.mat', ... + '../../../models/3D/mit.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D04/demo3D04.m b/demos/3D/demo3D04/demo3D04.m new file mode 100755 index 0000000..8217b74 --- /dev/null +++ b/demos/3D/demo3D04/demo3D04.m @@ -0,0 +1,74 @@ +function answer = demo3D04() +% demo3D04 +% +% Synthesize one 3D image with nuclear, cell shape, and microtubule +% channels from microtubule model without convolution. The model was +% trained from the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a valid CellOrganizer centrosome model file +% * a valid CellOrganizer microtubule model file +% +% Output +% ------ +% * three TIFF files (nuclear, cell shape, and microtubule channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D04' ); +disp( 'The estimated running time is 1 minutes. Please wait.' ); + +options.seed = 100; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.microscope = 'none'; +options.verbose = true; +options.debug = false; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/centro.mat'... + '../../../models/3D/tub.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D05/demo3D05.m b/demos/3D/demo3D05/demo3D05.m new file mode 100755 index 0000000..353cd7b --- /dev/null +++ b/demos/3D/demo3D05/demo3D05.m @@ -0,0 +1,80 @@ +function answer = demo3D05() +% demo3D05 +% +% Synthesize one 3D image with nuclear, cell shape, and protein channels +% from all object models (nucleoli, lysosomes, endosomes, mitochondria, and +% microtubules) with sampling method set to sample vesicular objects from +% Gaussians without convolution. The model was trained from the Murphy Lab +% 3D HeLa dataset. +% +% Input +% ----- +% * a list of valid CellOrganizer model files +% +% Output +% ------ +% * seven TIFF files (nuclear, cell shape, nucleolar, lysosomal, endosomal, +% mitochondrial, and microtubule channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D05' ); +disp( 'The estimated running time is 1 minutes. Please wait.' ); + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'sampled'; +options.verbose = true; +options.debug = false; +options.overwrite_synthetic_instances = false; +options.rendAtStd = 1.0; +options.objstd = options.rendAtStd+0.3; +options.overlapsubsize = 1; +options.numberOfGaussianObjects = 5; +options.output.OMETIFF = true; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/nuc.mat', ... + '../../../models/3D/lamp2.mat', ... + '../../../models/3D/tfr.mat', ... + '../../../models/3D/mit.mat', ... + '../../../models/3D/centro.mat'... + '../../../models/3D/tub.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D06/demo3D06.m b/demos/3D/demo3D06/demo3D06.m new file mode 100755 index 0000000..9c66d9d --- /dev/null +++ b/demos/3D/demo3D06/demo3D06.m @@ -0,0 +1,84 @@ +function answer = demo3D06() +% demo3D06 +% +% Synthesize one 3D image with nuclear, cell shape, and protein channels +% from all object models (nucleoli, lysosomes, endosomes, mitochondria, and +% microtubules) with sampling method set to render vesicular objects as +% ellipsoids and convolution with point-spread function. The model was +% trained from the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a list of valid CellOrganizer model files +% +% Output +% ------ +% * seven TIFF files (nuclear, cell shape, nucleolar, lysosomal, endosomal, +% mitochondrial, and microtubule channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D06' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 3 minutes. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.numberOfSynthesizedImages = 1; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.microscope = 'svi'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.numberOfGaussianObjects = 25; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/nuc.mat', ... + '../../../models/3D/lamp2.mat', ... + '../../../models/3D/tfr.mat', ... + '../../../models/3D/mit.mat', ... + '../../../models/3D/centro.mat'... + '../../../models/3D/tub.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D07/demo3D07.m b/demos/3D/demo3D07/demo3D07.m new file mode 100755 index 0000000..d73c596 --- /dev/null +++ b/demos/3D/demo3D07/demo3D07.m @@ -0,0 +1,84 @@ +function answer = demo3D07() +% demo3D07 +% +% Synthesize one 3D image with nuclear, cell shape, and protein channels +% from all object models (nucleoli, lysosomes, endosomes, mitochondria, and +% microtubules) with sampling method set to sample vesicular objects from +% Gaussians at a density of 25 and convolution with point-spread function. +% The model was trained from the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a list of valid CellOrganizer model files +% +% Output +% ------ +% * seven TIFF files (nuclear, cell shape, nucleolar, lysosomal, endosomal, +% mitochondrial, and microtubule channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D07' ); +disp( 'The estimated running time is 30 sec. Please wait.' ); + +options.seed = 100; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.numberOfSynthesizedImages = 1; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.microscope = 'svi'; +options.sampling.method = 'sampled'; +options.sampling.density = 25; +options.verbose = true; +options.debug = false; +options.numberOfGaussianObjects = 5; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/nuc.mat', ... + '../../../models/3D/lamp2.mat', ... + '../../../models/3D/tfr.mat', ... + '../../../models/3D/mit.mat', ... + '../../../models/3D/centro.mat'... + '../../../models/3D/tub.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D08/demo3D08.m b/demos/3D/demo3D08/demo3D08.m new file mode 100755 index 0000000..c96bbc7 --- /dev/null +++ b/demos/3D/demo3D08/demo3D08.m @@ -0,0 +1,82 @@ +function answer = demo3D08() +% demo3D08 +% +% Synthesize one 3D image with nuclear, cell shape, and vesicular channels +% from all vesicular object models (nucleoli, lysosomes, endosomes, and +% mitochondria) with sampling method set to render vesicular objects as +% ellipsoids without convolution. The model was trained from the Murphy Lab +% 3D HeLa dataset. +% +% Input +% ----- +% * a list of valid CellOrganizer model files +% +% Output +% ------ +% * single indexed TIFF file which indexes the six TIFF files (nuclear, +% cell shape, nucleolar, lysosomal, endosomal, and mitochondrial channels) + +% Created: Michelle Mackie +% +% Copyright (C) 2012-2017 Murphy Lab +% Lane Center for Computational Biology +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D08' ); +disp( 'The estimated running time is 4 minutes. Please wait.' ); + +options.seed = 100; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.numberOfSynthesizedImages = 1; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.image.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.indexedimage = true; +options.overlapthresh = 0; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/nuc.mat', ... + '../../../models/3D/lamp2.mat', ... + '../../../models/3D/tfr.mat', ... + '../../../models/3D/mit.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D09/demo3D09.m b/demos/3D/demo3D09/demo3D09.m new file mode 100755 index 0000000..dff182d --- /dev/null +++ b/demos/3D/demo3D09/demo3D09.m @@ -0,0 +1,80 @@ +function answer = demo3D09() +% demo3D09 +% +% Synthesize one 3D image with nuclear, cell shape, and lysosomal channels +% from LAMP2 model with sampling method set to render lysosomes as +% ellipsoids without convolution. Also render 2D mean projections along XY, +% XZ, and YZ axes of image. The model was trained from the Murphy Lab 3D +% HeLa dataset. +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * three TIFF files (nuclear, cell shape, and lysosomal channels) +% * one projection TIFF file +% * one projection PNG file + +% Created: Ivan E. Cao-Berg +% +% Copyright (C) 2012-2017 Murphy Lab +% Lane Center for Computational Biology +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +% July 21, 2012 murphy Additional documentation. +% August 10, 2012 icaoberg Reflected changes from img2projection + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D09' ); +disp( 'The estimated running time is 3 minutes. Please wait.' ); + +options.seed = 100; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.numberOfSynthesizedImages = 1; +options.prefix = 'img'; +options.image.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/lamp2.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D10/demo3D10.m b/demos/3D/demo3D10/demo3D10.m new file mode 100755 index 0000000..4cbefa1 --- /dev/null +++ b/demos/3D/demo3D10/demo3D10.m @@ -0,0 +1,78 @@ +function answer = demo3D10() +% demo3D10 +% +% Synthesize one 3D image with nuclear, cell shape, and lysosomal channels +% with object files that can be imported to Blender from LAMP2 model, +% with sampling method set to render lysosomes as ellipsoids without +% convolution. The model was trained from the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * three TIFF files (nuclear, cell shape, and lysosomal channels) +% * three Wavefront OBJ files (nuclear, cell shape, and lysosomal channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D10' ); +disp( 'The estimated running time is 3 minutes. Please wait.' ); + +options.seed = 100; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.numberOfSynthesizedImages = 1; +options.prefix = 'img'; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.tifimages = true; +options.output.blenderfile = true; +options.output.blender.downsample = 5; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/lamp2.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D11/demo3D11.m b/demos/3D/demo3D11/demo3D11.m new file mode 100755 index 0000000..3ecde60 --- /dev/null +++ b/demos/3D/demo3D11/demo3D11.m @@ -0,0 +1,133 @@ +function answer = demo3D11( options ) +% demo3D11 +% +% Train 3D generative model of the cell framework (nucleus and cell shape) +% using the Murphy Lab 3D HeLa LAMP2+TfR dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid model + +% Ivan E. Cao-Berg +% +% Copyright (C) 2012-2020 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +% May 15, 2013 @icaoberg Updated method to support wildcards +% +% February 2, 2016 @icaoberg Updated method to match the refactoring of +% CellOrganizer v2.5 +% +% March 4, 2016 @icaoberg Updated method so that it saves the resolution +% of the image collection. It will also force the values for +% options.model.resolution and options.downsampling if the flag +% options.use_preprocessed_images is set to true +% +% February 16, 2017 @icaoberg Changed demo to use a single pattern from the +% 3D HeLa dataset instead of the whole collection + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo3D11' ); +disp( 'The estimated running time is 5 minutes. Please wait.' ); + +options.sampling.method = 'disc'; +options.debug = true; +options.verbose = true; +options.display = false; +options.temporary_results = [ pwd filesep 'temporary_results' ]; +options.downsampling = [5,5,1]; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.model.filename = 'model.xml'; + +% generic model options +% --------------------- +options.model.name = '3d Hela framework model'; +options.model.id = num2str(now); + +% nuclear shape model options +% --------------------------- +options.nucleus.type = 'cylindrical_surface'; +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.name = 'all'; +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +options.cell.type = 'ratio'; +options.cell.class = 'cell_membrane'; +options.cell.model = 'framework'; +options.cell.id = num2str(now); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +options.model.resolution = [0.049, 0.049, 0.2000]; +directory = '../../../images/HeLa/3D/processed'; + +dimensionality = '3D'; + +%LAMP2 dataset +dna = {}; cellm = {}; protein = {}; options.masks = {}; options.labels = {}; + +for i = 1:25 + dna{i} = [directory filesep 'Nuc_cell' num2str(i) '_ch0_t1.tif']; + cellm{i} = [directory filesep 'Nuc_cell' num2str(i) '_ch1_t1.tif']; + protein{i} = [directory filesep 'Nuc_cell' num2str(i) '_ch2_t1.tif']; + options.labels{length(options.labels)+1} = 'Nucleoli'; + options.masks{i} = [directory filesep 'Nuc_cell' num2str(i) '_mask_t1.tif']; +end + +for i = 26:50 + dna{i} = [directory filesep 'LAM_cell' num2str(i) '_ch0_t1.tif']; + cellm{i} = [directory filesep 'LAM_cell' num2str(i) '_ch1_t1.tif']; + protein{i} = [directory filesep 'LAM_cell' num2str(i) '_ch2_t1.tif']; + options.labels{length(options.labels)+1} = 'LAMP2'; + options.masks{i} = [directory filesep 'LAM_cell' num2str(i) '_mask_t1.tif']; +end + +% documentation +% ------------- +options.documentation.author = 'Murphy Lab'; +options.documentation.email = 'murphy@cmu.edu'; +options.documentation.website = 'murphy@cmu.edu'; +options.documentation.description = 'This framework model is the result from demo3D11.'; +options.documentation.date = date; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = img2slml( dimensionality, dna, cellm, [], options ); \ No newline at end of file diff --git a/demos/3D/demo3D12/demo3D12.m b/demos/3D/demo3D12/demo3D12.m new file mode 100644 index 0000000..6b909cc --- /dev/null +++ b/demos/3D/demo3D12/demo3D12.m @@ -0,0 +1,119 @@ +function answer = demo3D12( options ) +% demo3D12 +% +% Train 3D generative model of the nucleus, cell shape, and lysosome using +% 30 Nuc images in the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * a directory of raw or synthetic lysosome images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Ivan E. Cao-Berg +% +% Copyright (C) 2012-2020 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo3D12' ); +disp( 'The estimated running time is 12 minutes. Please wait.' ); + +pattern = 'Nuc'; +dimensionality = '3D'; + +% generic model options +% --------------------- +options.model.name = 'all'; +options.model.id = num2str(now); + +% nuclear shape model options +% --------------------------- +% nucleus.type Holds the nuclear model type. Default is "cylindrical_surface". +options.nucleus.type = 'cylindrical_surface'; +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +options.cell.type = 'ratio'; +options.cell.id = num2str(now); +options.cell.class = 'cell_membrane'; + +% protein shape model options +% --------------------------- +% protein.type (optional) Holds the protein model type. The default is "vesicle". +options.protein.type = 'gmm'; +options.protein.class = 'vesicle'; +options.protein.id = num2str(now); + +% protein.cytonuclearflag (optional) Determines whether the protein pattern will be generated in +% the cytosolic space ('cyto'), nuclear space ('nuc') or everywhere ('all'). +% Default is cyto. +options.protein.cytonuclearflag = 'nuc'; + +% other options +% ------------- +options.verbose = true; +options.debug = true; +options.display = false; + +% documentation +% ------------- +options.documentation.description='This model has been trained using demo3D12 from CellOrganizer'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +directory = '../../../images/HeLa/3D/processed'; +dna = {}; cellm = {}; protein = {}; options.labels = {}; +for i = 1:25 + dna{i} = [directory filesep 'Nuc_cell' num2str(i) '_ch0_t1.tif']; + cellm{i} = [directory filesep 'Nuc_cell' num2str(i) '_ch1_t1.tif']; + protein{i} = [directory filesep 'Nuc_cell' num2str(i) '_ch2_t1.tif']; + options.labels{length(options.labels)+1} = 'Nucleoli'; + options.masks{i} = [directory filesep 'Nuc_cell' num2str(i) '_mask_t1.tif']; +end + +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'all' ))); +options.model.resolution=[0.049, 0.049, 0.2000]; +options.downsampling = [5,5,1]; +options.model.filename = 'model.xml'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = img2slml( dimensionality, dna, cellm, protein, options ); diff --git a/demos/3D/demo3D13/demo3D13.m b/demos/3D/demo3D13/demo3D13.m new file mode 100755 index 0000000..c8f57eb --- /dev/null +++ b/demos/3D/demo3D13/demo3D13.m @@ -0,0 +1,73 @@ +function answer = demo3D13() +% demo3D13 +% +% Export images synthesized by demo3D00 as object files importable to +% Blender. +% +% Input +% ----- +% * a directory of 3D synthetic images +% +% Output +% ------ +% * Wavefront OBJ files + +% Ivan E. Cao-Berg +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D13' ); +disp( 'The estimated running time is 30 seconds. Please wait.' ); + +options.downsample = 5; +options.verbose = true; +options.debug = true; +answer = false; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +synthesized_images_directory = '../demo3D00/img/cell1'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +if ~exist( synthesized_images_directory ) + warning( 'Synthetic image directory does not exist. Exiting demo.' ); + return +else + output_folder = [ pwd filesep 'blender' ]; + if ~exist( output_folder ) + mkdir( output_folder ); + end + + answer = syn2blender( synthesized_images_directory, ... + output_folder, options ); +end diff --git a/demos/3D/demo3D14/demo3D14.m b/demos/3D/demo3D14/demo3D14.m new file mode 100755 index 0000000..72348d0 --- /dev/null +++ b/demos/3D/demo3D14/demo3D14.m @@ -0,0 +1,74 @@ +function answer = demo3D14() +% demo3D14 +% +% Render 2D mean projections along XY, XZ, and YZ axes of images +% synthesized by demo3D00. +% +% Input +% ----- +% * a directory of 3D synthetic images +% +% Output +% ------ +% * projections of synthetic images as TIFF files + +% Ivan E. Cao-Berg +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D14' ); +disp( 'The estimated running time is 30 seconds. Please wait.' ); + +options.verbose = true; +options.debug = true; +options.method = 'mean'; +options.compression = 'lzw'; +answer=false; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +synthesized_images_directory = '../demo3D00/img/cell1'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +if ~exist( synthesized_images_directory ) + warning( 'Synthetic images directory does not exist. Exiting demo.' ); + return; +else + output_folder = [ pwd filesep 'projections' ]; + if ~exist( output_folder ) + mkdir( output_folder ); + end + + answer = syn2projection( synthesized_images_directory, ... + output_folder, options ); +end diff --git a/demos/3D/demo3D15/demo3D15.m b/demos/3D/demo3D15/demo3D15.m new file mode 100644 index 0000000..5d7096b --- /dev/null +++ b/demos/3D/demo3D15/demo3D15.m @@ -0,0 +1,87 @@ +function answer = demo3D15() +% demo3D15 +% +% Synthesize one multichannel 3D image from an endosomal model and +% diffeomorphic nuclear and cell shape model. The sampling method was set +% to render endosomes as ellipsoids without convolution. The model was +% trained from the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a valid CellOrganizer model file with a diffeomorphic framework +% +% Output +% ------ +% * three TIFF files (nuclear, cell shape, and endosomal channels) + +% Ivan E. Cao-Berg +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D15' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); + +options.seed = 1234558; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +outputDirectory = pwd; +options = []; +options.targetDirectory = outputDirectory; +options.prefix = 'img'; +options.numberOfSynthesizedImages = 1; +options.numberOfGaussianObjects = 5; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.synthesis = 'all'; + +filename = '../../../models/3D/diffeomorphic/HeLa_diffeo_framework_and_LAMP2.mat'; +if ~exist( filename ) + warning(['Unable to load model: ' filename ' . Exiting method.'] ); + return +else + load( filename ); +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = { filename }; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); diff --git a/demos/3D/demo3D16/demo3D16.m b/demos/3D/demo3D16/demo3D16.m new file mode 100644 index 0000000..ee59c3f --- /dev/null +++ b/demos/3D/demo3D16/demo3D16.m @@ -0,0 +1,95 @@ +function answer = demo3D16() +% demo3D16 +% +% The main idea behind this demo is to show the user they +% can use their own binary images from raw experimental data +% to synthesize protein patterns. This demo uses the CellOrganizer +% method for nuclear and cell segmentation. +% +% The current demo assumes the resolution of the images is the same as +% the resolution of the images that were used to train the protein model. +% +% Input +% ----- +% * raw or synthetic images of the nuclear and cell membrane +% * a valid CellOrganizer model file +% +% Output +% ------ +% * three TIFF files (cell shape, nuclear, and lysosomal channels) + +% Ivan E. Cao-Berg +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D16' ); +disp( 'The estimated running time is 3 hours. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.numberOfSynthesizedImages = 1; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.display = false; +options.synthesis = 'all'; +options.train.flag = 'all'; +options.resolution.cell = [0.049, 0.049, 0.2000]; +downsample = [1 1 1]; +options.resolution.cell = options.resolution.cell.*downsample; +options.preprocessingFolder = 'temp'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +directory = '../../../images/HeLa/3D/raw'; +dna_image_file = [ directory filesep 'LAM_cell1_ch0_t1.tif' ]; +cell_image_file = [ directory filesep 'LAM_cell1_ch1_t1.tif' ]; +prot_image_file = [ directory filesep 'LAM_cell1_ch2_t1.tif' ]; +mask_image_file = [ directory filesep 'LAM_cell1_mask_t1.tif' ]; +options.instance.resolution=[0.049, 0.049, 0.2000]; + +[options.instance.nucleus, options.instance.cell ] = ... + seg_cell_and_nucleus( dna_image_file, ... + cell_image_file, ... + prot_image_file, ... + mask_image_file, ... + downsample, options.display, options ); + +answer = slml2img( {'../../../models/3D/lamp2.mat'}, options ); diff --git a/demos/3D/demo3D17/demo3D17.m b/demos/3D/demo3D17/demo3D17.m new file mode 100644 index 0000000..d8b4027 --- /dev/null +++ b/demos/3D/demo3D17/demo3D17.m @@ -0,0 +1,98 @@ +function answer = demo3D17() +% demo3D17 +% +% The main idea behind this demo is to show the user they +% can use their own binary images from raw experimental data +% to synthesize protein patterns. +% +% The current demo assumes the resolution of the images is the same +% as the resolution of the images that were used to train the protein model. +% +% Input +% ----- +% * an existing raw or synthetic framework, i.e. one binary multi-TIFF +% file of the nuclear channel and one binary multi-TIFF file of the +% cell membrane +% * the resolution of the latter images +% * a valid CellOrganizer model that contains a protein model +% +% Output +% ------ +% * three TIFF files (cell shape, nuclear, and lysosomal channels) + +% Ivan E. Cao-Berg +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D17' ); +disp( 'The estimated running time is 2 minutes. Please wait.' ); + +try + state = rng(3); +catch + state = RandStream.create('mt19937ar','seed',3); + RandStream.setDefaultStream(state); +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +%step0: set the input parameters described in the header +%step0.1 use existing raw or synthetic frameworks: in this demo we are going +%to use an image from the Murphy Lab 3D HeLa collection that you can download +%along with CellOrganizer. + +filename = '../../../images/HeLa/3D/processed/LAM_cell10_ch0_t1.tif'; +param.instance.nucleus = tif2img( filename ); +filename = '../../../images/HeLa/3D/processed/LAM_cell10_ch1_t1.tif'; +param.instance.cell = tif2img( filename ); + +%step0.2: set the resolution of the latter images +param.instance.resolution = [0.049, 0.049, 0.2000]; + +%step0.3: use a valid CellOrganizer model that contains a protein model. in +%this model we are going to use the 3D HeLa nucleoli model distrubuted in +%this version of CellOrganizer +model_file_path = '../../../models/3D/nuc.mat'; + +%these are optional parameters that you are welcome to modify as needed +%location where CellOrganizer will save the images to +param.targetDirectory = pwd; +param.prefix = 'img'; +param.numberOfSynthesizedImages = 1; +param.output.tifimages = true; +param.compression = 'lzw'; +param.microscope = 'none'; +param.sampling.method = 'disc'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( {model_file_path}, param ); diff --git a/demos/3D/demo3D18/demo3D18.m b/demos/3D/demo3D18/demo3D18.m new file mode 100755 index 0000000..eb205d8 --- /dev/null +++ b/demos/3D/demo3D18/demo3D18.m @@ -0,0 +1,164 @@ +function answer = demo3D18(options) +% demo3D18 +% +% Train 3D generative model of the cell framework (nucleus and cell shape), +% using hole-finding to infer both nucleus and cell shape from the supplied +% protein pattern. The 3D 3T3 dataset was collected in collaboration with +% Dr. Jonathan Jarvik and Dr. Peter Berget. +% +% Input +% ----- +% * a directory of raw or synthetic protein images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model + +% Ivan E. Cao-Berg +% +% Copyright (C) 2013-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo3D18' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 2 minutes. Please wait.' ); + +options.seed = 100; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +% generic model options +% --------------------- +% model.name (optional) Holds the name of the model. Default is empty. +options.model.name = '3D_3T3_framework'; + +% model.id (optional) Holds the id of the model. Default is empty. +options.model.id = num2str(now); + +% model.filename Holds the output filename. +options.model.filename = 'model.xml'; + +% nuclear shape model options +% --------------------------- +% nucleus.type Holds the nuclear model type. Default is "medial axis". +options.nucleus.type = 'cylindrical_surface'; + +% nucleus.id (optional) Holds the id of the nuclear model. Default is empty. +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +% cell.type Holds the cell model type. Default is "ratio". +options.cell.type = 'ratio'; + +% cell.id (optional) Holds the id the cell model. Default is empty. +options.cell.id = num2str(now); + +% other options +% ------------- +% verbose (optional) Displays messages to screen. The default is true. +options.verbose = true; + +% debug (optional) Reports errors and warnings. Default is false. +options.debug = true; + +% display (optional) Shows displays of intermediate steps +options.display = true; + +% train.flag (optional) Selects what model is going to be trained ('nuclear', +% 'framework', or 'all'). Default is 'all' +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +% this demo expects 3D tiff images in this directory and +% crop files containing a mask for each cell in a masks subdirectory +imdir = [ pwd filesep '../../../images/3T3/3D/']; +cropdir = [imdir 'masks/']; + +files = dir([imdir '*.tif']); +files = sort_nat({files.name}); + +for i = 1:length(files) + cell{i} = [imdir files{i}]; +end + +options.masks = [cropdir filesep '*crop.tif']; + +%documentation +options.documentation.description = 'This model has been trained using demo3D18 from CellOrganizer'; +options.documentation.dataset = '3D 3T3'; +options.documentation.dataset_reference = 'K. Huang and R. F. Murphy (2004) From Quantitative Microscopy to Automated Image Understanding. J. Biomed. Optics 9: 893-912.'; +options.documentation.dataset_hyperlink = 'http://murphylab.web.cmu.edu/data/#3D3T3'; +options.documentation.author = 'Gregory Johnson'; +options.documentation.email = 'gj@andrew.cmu.edu'; +options.documentation.copyright = 'Copyright (c) 2007-2017 by the Murphy Lab, Carnegie Mellon University'; + +%model dimensionality +dimensionality = '3D'; + +%dataset resolution +options.model.resolution = [0.11, 0.11, 0.5]; + +%downsampling vector +options.downsampling = [8, 8, 1]; + +% these control cell segmentation preprocessing (see preprocess) +options.preprocess.stiffness = 0.2; %was originally 0.7 +options.preprocess.maxiter = 3000; %same as default +%options.preprocess.quittol = 0.00001; %this is the default +options.preprocess.quittol = 0.0001; %use higher tolerance for speed + +% can set this to force single value for nuclear hole finding +% although this is probably not needed (see findDnaMask) +%options.stiffness = ? + +% this controls rejecting nuclear hole finding if its volume is too small +options.segminnucfraction = 0.04; + +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.type = 'cylindrical_surface'; + +options.cell.class = 'cell_membrane'; +options.cell.type = 'ratio'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = img2slml( dimensionality, [], cell, [], options ); +end diff --git a/demos/3D/demo3D19/demo3D19.m b/demos/3D/demo3D19/demo3D19.m new file mode 100755 index 0000000..96bd4cc --- /dev/null +++ b/demos/3D/demo3D19/demo3D19.m @@ -0,0 +1,56 @@ +function answer = demo3D19() +% demo3D19 +% +% This demo uses slml2report to compare the parameters between +% CellOrganizer models and returns a report. +% +% Input +% ----- +% * a set of valid CellOrganizer models +% +% Output +% ------ +% * a report + +% Gregory Johnson +% +% Copyright (C) 2013-2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D19' ); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +directory = '../../../models/3D/'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +disp('Generating report using only protein parameters'); +answer = slml2report([directory 'nuc.mat'], [directory 'lamp2.mat'] ); +end diff --git a/demos/3D/demo3D20/demo3D20.m b/demos/3D/demo3D20/demo3D20.m new file mode 100644 index 0000000..4c6aa6c --- /dev/null +++ b/demos/3D/demo3D20/demo3D20.m @@ -0,0 +1,99 @@ +function answer = demo3D20(options) +% demo3D20 +% +% Train 3D generative diffeomorphic model of the cell framework (nucleus +% and cell shape) using 10 images Murphy Lab 3D HeLa LAMP2 dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * a directory of raw or synthetic lysosome images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------- +% * a valid SLML model file +% * a visualization of the shape space + +% Gregory Johnson +% +% Copyright (C) 2013-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo3D20' ); +disp( 'The estimated running time is 30 minutes. Please wait.' ); + +dimensionality = '3D'; + +% other options +% ------------- +options.verbose = true; +options.debug = true; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); + +% generic model options +% --------------------- +options.model.name = 'demo3D20'; +options.model.id = num2str(now); +options.model.filename = 'model.xml' ; + +% nuclear shape model options +% --------------------------- +options.nucleus.type = 'diffeomorphic'; +options.nucleus.class = 'framework'; +options.nucleus.id = num2str(now); +options.nucleus.name = 'lamp2'; + +% cell shape model options +% ------------------------ +options.cell.type = 'diffeomorphic'; +options.cell.class = 'framework'; +options.cell.model = 'lamp2'; +options.cell.id = num2str(now); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +directory = '../../../images/HeLa/3D/processed'; +dna = [directory filesep 'LAM_cell*_ch0_t1.tif']; +cellm = [directory filesep 'LAM_cell*_ch1_t1.tif']; +options.masks = [directory filesep 'LAM_cell*_mask_t1.tif']; +options.model.resolution = [0.049, 0.049, 0.2000]; +options.downsampling = [5,5,1]; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = img2slml( dimensionality, dna, cellm, [], options ); +end%demo3D20 diff --git a/demos/3D/demo3D21/demo3D21.m b/demos/3D/demo3D21/demo3D21.m new file mode 100755 index 0000000..97dc204 --- /dev/null +++ b/demos/3D/demo3D21/demo3D21.m @@ -0,0 +1,116 @@ +function answer = demo3D21(options) +% demo3D21 +% +% Train 3D generative model of the cell framework (nucleus and cell shape), +% using hole-finding to infer both nucleus and cell shape from the supplied +% protein pattern. This is identical to demo3D18 minus scaling the +% images. The 3D 3T3 dataset was collected in collaboration with Dr. +% Jonathan Jarvik and Peter Berget. +% +% Input +% ----- +% * a directory of raw or synthetic protein images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model + +% Ivan E. Cao-Berg +% +% Copyright (C) 2013-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo3D21' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 30 minutes. Please wait.' ); + +%documentation +options.documentation.description = 'This model has been trained using demo3D21 from CellOrganizer'; +options.documentation.dataset = '3D 3T3'; +options.documentation.dataset_reference = 'K. Huang and R. F. Murphy (2004) From Quantitative Microscopy to Automated Image Understanding. J. Biomed. Optics 9: 893-912.'; +options.documentation.dataset_hyperlink = 'http://murphylab.web.cmu.edu/data/3D3T3'; +options.documentation.author = 'Gregory Johnson'; +options.documentation.email = 'gj@andrew.cmu.edu'; +options.documentation.copyright = 'Copyright (c) 2007-2017 by the Murphy Lab, Carnegie Mellon University'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +imdir = '../../../images/3T3/3D'; +cropdir = [ imdir filesep 'masks' ]; +files = dir([imdir filesep '*.tif']); +files = sort_nat({files.name}); + +for i = 1:length(files) + cell{i} = @() flipdim(ml_readimage([imdir filesep files{i}]),3); +end + +options.masks = [cropdir filesep '*crop.tif']; + +% generic model options +% --------------------- +options.model.name = '3D_3T3_framework'; +options.model.id = num2str(now); +options.model.filename = 'model.xml'; + +% nuclear shape model options +% --------------------------- +options.nucleus.type = 'cylindrical_surface'; +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +options.cell.type = 'ratio'; +options.cell.class = 'cell_membrane'; +options.cell.id = num2str(now); + +% other options +% ------------- +options.verbose = true; +options.debug = false; + +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); + +%model dimensionality +dimensionality = '3D'; + +%dataset resolution +options.model.resolution = [0.11, 0.11, 0.5]; + +%downsampling vector +options.downsampling = [8, 8, 1]; + +%run demo and make profile +answer = img2slml( dimensionality, [], cell, [], options ); +end%demo3D321 \ No newline at end of file diff --git a/demos/3D/demo3D22/demo3D22.m b/demos/3D/demo3D22/demo3D22.m new file mode 100755 index 0000000..85847d3 --- /dev/null +++ b/demos/3D/demo3D22/demo3D22.m @@ -0,0 +1,98 @@ +function answer = demo3D22() +% demo3D22 +% +% Synthesizes a protein pattern instance from the synthetic image produced +% in demo3D00. +% +% Input +% ----- +% * a synthetic framework +% +% Output +% ------ +% * a synthetic image + +% Devin Sullivan +% +% Copyright (C) 2014-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D22' ); +disp( 'The estimated running time is 30 seconds. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +try + folder = '../demo3D00/img'; + copyfile( folder ); +catch err + warning('Unable to copy files. Exiting demo'); + getReport(err) + return +end + +options = []; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.numberOfSynthesizedImages = 1; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.synthesis = 'all'; + +%make sure objects don't overlap. +options.rendAtStd = 1; +options.objstd = 1.1; +options.overlapsubsize = 1; +options.output.tifimages = 1; +options.numberOfGaussianObjects = 50; + +options.model.resolution = [0.049, 0.049, 0.2000]; +options.resolution.cell = [0.049, 0.049, 0.2000]; +img = tif2img( [ pwd filesep 'cell1' filesep 'nucleus.tif' ] ); +options.instance.nucleus = img; +options.instance.resolution= [0.049, 0.049, 0.2000]; +clear img + +img = tif2img( [ pwd filesep 'cell1' filesep 'cell.tif' ] ); +options.instance.cell = img; +clear img + +answer = slml2img( {'../../../models/3D/tfr.mat'}, options ); +end%demo3D22 diff --git a/demos/3D/demo3D23/demo3D23.m b/demos/3D/demo3D23/demo3D23.m new file mode 100644 index 0000000..804b88b --- /dev/null +++ b/demos/3D/demo3D23/demo3D23.m @@ -0,0 +1,131 @@ +function answer = demo3D23( options ) +% demo3D23 +% +% Train 3D generative diffeomorphic nuclear, cell shape, and a +% lysosomal model from all LAMP2 images in the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * a directory of raw or synthetic lysosome images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Gregory Johnson +% +% Copyright (C) 2013-2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo3D23' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 9 hours. Please wait.' ); + +pattern = 'LAMP2'; + +directory = '../../../images/HeLa/3D/processed'; +dna = [directory filesep 'LAM*cell*ch0*.tif']; +cellm = [directory filesep 'LAM*cell*ch1*.tif']; +protein = [directory filesep 'LAM*cell*ch2*.tif']; +options.masks = [directory filesep 'LAM*cell*mask*.tif']; + +dimensionality = '3D'; + +% options.masks = [directory filesep 'cell*mask*.tif']; + +% generic model options +% --------------------- +% model.name (optional) Holds the name of the model. Default is empty. +options.model.name = 'all'; + +% model.id (optional) Holds the id of the model. Default is empty. +options.model.id = num2str(now); + +% model.filename Holds the output filename. +options.model.filename = [ lower(pattern) '.xml' ]; + +% nucleus.id (optional) Holds the id of the nuclear model. Default is empty. +options.nucleus.type = 'diffeomorphic'; +options.nucleus.class = 'framework'; +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +% cell.type Holds the cell model type. Default is "ratio". +options.cell.type = 'diffeomorphic'; +options.cell.class = 'framework'; +options.cell.id = num2str(now); + +% protein shape model options +% --------------------------- +% protein.type (optional) Holds the protein model type. The default is "vesicle". +options.protein.type = 'gmm'; +options.protein.class = 'vesicle'; +options.protein.id = num2str(now); + +% protein.cytonuclearflag (optional) Determines whether the protein pattern will be generated in +% the cytosolic space ('cyto'), nuclear space ('nuc') or everywhere ('all'). +% Default is cyto. +if strcmpi( options.protein.class, 'nuc' ) + options.protein.cytonuclearflag = 'nuc'; +else + options.protein.cytonuclearflag = 'cyto'; +end + +% other options +% ------------- +% verbose (optional) Displays messages to screen. The default is true. +options.verbose = true; + +% debug (optional) Reports errors and warnings. Default is false. +options.debug = false; + +% train.flag (optional) Selects what model is going to be trained ('nuclear', +% 'framework', or 'all'). Default is 'all' +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'all' ))); + +%documentation +options.documentation.description = 'This model has been trained using demo3D20 from CellOrganizer'; + +%model resolution +options.downsampling = [10,10,1]; + +%this is the resolution of the datasets +options.model.resolution = [0.049, 0.049, 0.2000]; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = img2slml( dimensionality, dna, cellm, protein, options ); diff --git a/demos/3D/demo3D24/Marcon et al. 2016 - Figure 2c Type III.xml b/demos/3D/demo3D24/Marcon et al. 2016 - Figure 2c Type III.xml new file mode 100644 index 0000000..91843af --- /dev/null +++ b/demos/3D/demo3D24/Marcon et al. 2016 - Figure 2c Type III.xml @@ -0,0 +1,495 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/3D/demo3D24/demo3D24.m b/demos/3D/demo3D24/demo3D24.m new file mode 100644 index 0000000..8d96be6 --- /dev/null +++ b/demos/3D/demo3D24/demo3D24.m @@ -0,0 +1,119 @@ +function answer = demo3D24( options ) +% demo3D24 +% +% This demo converts a sample SBML file to an SBML-spatial instance using +% the "matchSBML" function. This function takes an SBML file, matches the +% compartments in the file with available models and synthesizes the +% appropriate instances. +% +% Input +% ----- +% * sample SBML file +% +% Output +% ------ +% * valid SBML model + +% Devin Sullivan +% +% Copyright (C) 2014-2019 Murphy Lab +% Lane Center for Computational Biology +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +use_profiling = false; +% use_profiling = true; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D24' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 1 minute. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.numberOfSynthesizedImages = 1; +options.numberOfGaussianObjects = 1; +options.prefix = 'img'; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.tifimages = true; +options.rendAtStd = 1; +options.objstd = 1.1; +options.overlapsubsize = 1; + +filename = 'Motivating_example_cBNGL2_13_sbml.xml'; +url = 'http://www.cellorganizer.org/Downloads/files'; + +% options.output.SBML = 'Motivating_example_cBNGL2_13_sbml.xml'; + +options.output.SBMLSpatial = 'Marcon et al. 2016 - Figure 2c Type III.xml'; +options.output.SBMLSpatialVCellCompatible = true; +options.output.SBMLSpatialUseCompression = true; +options.output.SBMLSpatialImage = true; +options.output.SBMLDownsampling = [1/16, 1/16, 1]; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +% note, the framework will be synthesized using the first protein model +% found to match the given patterns in the SBML file. +% Changing the order/priority of this is not supported at this time. +modelpaths = {'../../../models/3D/tfr.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +if use_profiling + profile off; profile('-memory','on'); profile off; profile on; +end + +options +options_output = options.output + +answer = slml2img(modelpaths,options); + +xml_source_filename = [options.prefix, '/cell1/cell.xml']; +xml_destination_filename = [options.prefix, '.xml']; +copyfile(xml_source_filename, xml_destination_filename); + +if use_profiling + profile_results = profile('info'); + profile_filename = ['profile_results', '.mat']; + profsave(profile_results, [profile_filename, '_html']); + save(profile_filename, 'profile_results'); +end + +end%demo3D24 \ No newline at end of file diff --git a/demos/3D/demo3D25/demo3D25.m b/demos/3D/demo3D25/demo3D25.m new file mode 100755 index 0000000..c6cfd6e --- /dev/null +++ b/demos/3D/demo3D25/demo3D25.m @@ -0,0 +1,82 @@ +function answer = demo3D25() +% demo3D25 +% +% Synthesizes 1 image using a lysosomal model with sampling mode +% set to 'disc', no convolution and output.SBML set to true. +% Results will be three TIFF files, one each for cell boundary, +% nuclear boundary, and lysosomes, in folder "synthesizedImages/cell1" +% Additionally, in the folder "synthesizedImages/" will be a +% SBML-Spatial(v0.82a) formatted .xml file containing constructed solid +% geometry(CSG) primitives for lysosomes and parametric objects for the +% cell and nuclear shapes. +% +% These files can then be read into VCell using the built in importer or +% CellBlender using the helper function provided in this distribution. +% +% Input +% ----- +% * valid SBML model +% +% Output +% ------ +% * three TIFF files +% * XML file with primitives for lysosomes and parametric objects + +% Devin Sullivan +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +answer = false; +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +outputDirectory = pwd; +param = []; +param.targetDirectory = outputDirectory; +param.prefix = 'img'; +param.numberOfSynthesizedImages = 1; +param.compression = 'lzw'; +param.microscope = 'none'; +param.sampling.method = 'disc'; +param.verbose = true; +param.debug = false; +param.output.blenderfile = true; +param.output.blender.downsample = 5; +param.output.tifimages = true; +param.output.SBML = true; + +answer = slml2img( {'../../../models/3D/lamp2.mat'}, param ); \ No newline at end of file diff --git a/demos/3D/demo3D26/demo3D26.m b/demos/3D/demo3D26/demo3D26.m new file mode 100644 index 0000000..c434ae0 --- /dev/null +++ b/demos/3D/demo3D26/demo3D26.m @@ -0,0 +1,66 @@ +function answer = demo3D26() +% demo3D26 +% +% This function displays a shape space of some dimensionality. This demo +% uses the model trained in Johnson 2015. +% +% Input +% ----- +% * a CellOrganizer diffeomorphic model +% +% Output +% ------ +% * a display of the shape space + +% Copyright (C) 2016-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D26' ); +disp( 'The estimated running time is 2 hours and 40 minutes. Please wait.' ); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +modelname = 'helamodel_9_16_15.mat'; + +disp(['Loading ' modelname '. This might take a few minutes']); +try + load(['../../../models/3D/diffeomorphic/' modelname]) +catch + warning( 'Unable to load model. Exiting demo.' ); + getReport(err) + return +end +disp([modelname ' loaded.']) + +disp(['Warning: building the display of the shape space ' ... + 'requires considerable resources. Please be patient.']); +test_reconstruction_methods( model.cellShapeModel.distances_incomplete ) +answer = true; +end%demo3D26 diff --git a/demos/3D/demo3D27/demo3D27.m b/demos/3D/demo3D27/demo3D27.m new file mode 100644 index 0000000..23df620 --- /dev/null +++ b/demos/3D/demo3D27/demo3D27.m @@ -0,0 +1,151 @@ +function answer = demo3D27() +% demo3D27 +% +% This demo performs a regression between two sets of related shapes (i.e. +% predicts cell shape from nuclear shape) and displays the residuals as in +% Figure 2 of Johnson et al 2015. +% +% Input +% ----- +% * models hela_cell_10_15_15.mat and hela_nuc_10_15_15.mat +% +% Output +% ------ +% * shape space figure + +% Copyright (C) 2016-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D27' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 2 hours. Please wait.' ); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +current_path = which(mfilename); +[current_path, filename, extension] = fileparts( current_path ); +cd(current_path); + +modelpath = which(mfilename); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +modelCell = load('../../../models/3D/diffeomorphic/hela_cell_10_15_15.mat'); +modelNuc = load('../../../models/3D/diffeomorphic/hela_nuc_10_15_15.mat'); + +distances_incomplete_cell = modelCell.model.cellShapeModel.distances_incomplete; +distances_incomplete_nuc = modelNuc.model.cellShapeModel.distances_incomplete; + +[ keepinds_cell ] = get_complete_distance_matrix( distances_incomplete_cell); +[ keepinds_nuc ] = get_complete_distance_matrix( distances_incomplete_nuc); + +keepinds = intersect(keepinds_cell, keepinds_nuc); + +cellpos = modelCell.model.cellShapeModel.positions(keepinds, :); +nucpos = modelNuc.model.cellShapeModel.positions(keepinds, :); + +ndat = size(cellpos,1); + +c2ndir = [pwd filesep 'c2n']; +n2cdir = [pwd filesep 'n2c']; + +c2n = kernel_pred_iter(cellpos, nucpos, 1:ndat, 0, c2ndir); +n2c = kernel_pred_iter(nucpos, cellpos, 1:ndat, 0, n2cdir); + +[cell2nuc_dist_pval, cell2nuc_pred_norm_err] = pred_pval(nucpos, c2n.y_pred); +[nuc2cell_dist_pval, nuc2cell_pred_norm_err] = pred_pval(cellpos, n2c.y_pred); + +imfunc_cell = modelCell.model.cellShapeModel.imfunc; +imfunc_nuc = modelNuc.model.cellShapeModel.imfunc; + +param.subsize = 150; + +pmax = max([cell2nuc_dist_pval; nuc2cell_dist_pval]); + +boundpad = 0.25; + +positions_nuc_norm = zeros(size(nucpos)); +positions_nuc_norm(:) = zscore(nucpos(:)); + +positions_cell_norm = zeros(size(cellpos)); +positions_cell_norm(:) = zscore(cellpos(:)); + +colors = nan(ndat,3); +colors(keepinds,:) = grayrange2rgb(cell2nuc_dist_pval, 0,pmax); + +model = modelCell.model; +model.cellShapeModel.positions = nan(size(model.cellShapeModel.positions,1), size(positions_nuc_norm,2)); +model.cellShapeModel.positions(keepinds,:) = positions_nuc_norm; + +param.imfunc = @(x) (im2projection_RGB(permute(cropImg(imfunc_cell(x),0),[2,1,3]),struct('scale_inten', 2, 'justz', true, 'cm', @(y) colormap(colors(x,:))))); + +mkdir img; + +h(1) = figure; +showShapeSpaceFigure(model,[], param); + +minpos = min(model.cellShapeModel.positions,[],1); +maxpos = max(model.cellShapeModel.positions,[],1); +axis([minpos(1)-boundpad maxpos(1)+boundpad minpos(2)-boundpad maxpos(2) + boundpad]) + +param.imfunc = @(x) (im2projection_RGB(permute(cropImg(imfunc_nuc(x),0),[2,1,3]),struct('scale_inten', 2, 'justz', true, 'cm', @(y) colormap(colors(x,:))))); +saveas( gcf, './img/output01.png' ); + +h(2) = figure; +showShapeSpaceFigure(model,[], param); + +axis([minpos(1)-boundpad maxpos(1)+boundpad minpos(2)-boundpad maxpos(2) + boundpad]); + +colors = nan(ndat,3); +colors(keepinds,:) = grayrange2rgb(nuc2cell_dist_pval, 0,pmax); + +model.cellShapeModel.positions = nan(size(model.cellShapeModel.positions,1), size(positions_cell_norm,2)); +model.cellShapeModel.positions(keepinds,:) = positions_cell_norm; + +param.imfunc = @(x) (im2projection_RGB(permute(cropImg(imfunc_cell(x),0),[2,1,3]),struct('scale_inten', 2, 'justz', true, 'cm', @(y) colormap(colors(x,:))))); +saveas( gcf, './img/output02.png' ); + +h(3) = figure; +showShapeSpaceFigure(model,[], param); + +minpos = min(model.cellShapeModel.positions,[],1); +maxpos = max(model.cellShapeModel.positions,[],1); +axis([minpos(1)-boundpad maxpos(1)+boundpad minpos(2)-boundpad maxpos(2) + boundpad]) + +param.imfunc = @(x) (im2projection_RGB(permute(cropImg(imfunc_nuc(x),0),[2,1,3]),struct('scale_inten', 2, 'justz', true, 'cm', @(y) colormap(colors(x,:))))); +saveas( gcf, './img/output03.png' ); + +h(4) = figure; +showShapeSpaceFigure(model,[], param); +axis([minpos(1)-boundpad maxpos(1)+boundpad minpos(2)-boundpad maxpos(2) + boundpad]); +saveas( gcf, './img/output04.png' ); +answer = true; +end%demo3D27 \ No newline at end of file diff --git a/demos/3D/demo3D28/demo3D28.m b/demos/3D/demo3D28/demo3D28.m new file mode 100644 index 0000000..5c39a28 --- /dev/null +++ b/demos/3D/demo3D28/demo3D28.m @@ -0,0 +1,110 @@ +function answer = demo3D28() +% demo3D28 +% +% Synthesize one 3D image with nuclear, cell shape, and nucleolar channels +% from nucleolar model with sampling method set to render nucleoli as +% ellipsoids without convolution. The model was trained from the Murphy Lab +% 3D HeLa dataset. +% +% Input +% ----- +% * an existing raw or synthetic nuclear image, i.e. one binary multi-TIFF +% file of the nuclear channel +% * the resolution of the input image +% * a valid CellOrganizer model that contains a cell membrane model +% +% Output +% ------ +% * three TIFF files (cell shape, nuclear, and nucleolar channels) + +% Ivan E. Cao-Berg +% +% Copyright (C) 2016-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D28' ); +disp( 'The estimated running time is 1 minute. Please wait.' ); + +options.seed = 3; +try + state = rng(options.seed); +catch + state = RandStream.create('mt19937ar','seed',options.seed); + RandStream.setGlobalStream(state); +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +%step0: set the input parameters described in the header +%step0.1 use existing raw or synthetic frameworks: in this demo we are going +%to use an image from the Murphy Lab 3D HeLa collection that you can download +%along with CellOrganizer. +filename = '../../../images/HeLa/3D/processed/LAM_cell10_ch0_t1.tif'; +options.instance.nucleus = tif2img( filename ); + +%step0.2: set the resolution of the latter images +options.instance.resolution = [0.049, 0.049, 0.2000]; + +%step0.3: use a valid CellOrganizer model that contains a protein model. in +%this model we are going to use the 3D HeLa nucleoli model distributed in +%this version of CellOrganizer +model_file_path = '../../../models/3D/nuc.mat'; + +%these are optional parameters that you are welcome to modify as needed +%location where CellOrganizer will save the images to +options.targetDirectory = pwd; + +%output folder name +options.prefix = 'img'; + +%number of images to synthesize +options.numberOfSynthesizedImages = 1; + +%save images as TIF files +options.output.tifimages = true; + +%compression for TIF output +options.compression = 'lzw'; + +%do not apply point-spread-function +options.microscope = 'none'; + +%render Gaussian objects as discs +options.sampling.method = 'disc'; + +%synthesize for all channels +options.synthesis = 'all'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%main call to CellOrganizer +answer = slml2img( {model_file_path}, options ); +end%demo3D28 \ No newline at end of file diff --git a/demos/3D/demo3D29/demo3D29.m b/demos/3D/demo3D29/demo3D29.m new file mode 100644 index 0000000..731bccc --- /dev/null +++ b/demos/3D/demo3D29/demo3D29.m @@ -0,0 +1,58 @@ +function answer = demo3D29() +% demo3D29 +% +% Displays information about a model +% +% Input +% ----- +% * valid model +% +% Output +% ------ +% * details about the models + +% Ivan E. Cao-Berg +% +% Copyright (C) 2017-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D29' ); +disp( 'The estimated running time is 1 minute. Please wait.' ); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +directory = '../../../models/3D/'; +instance = {[directory filesep 'ellipsoid_model.mat']}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2info(instance); +end%demo3D47 diff --git a/demos/3D/demo3D30/demo3D30.m b/demos/3D/demo3D30/demo3D30.m new file mode 100644 index 0000000..99023ac --- /dev/null +++ b/demos/3D/demo3D30/demo3D30.m @@ -0,0 +1,147 @@ +function answer = demo3D30() +% demo3D30 +% +% This demo illustrates different ways to sample from points in a +% diffeomorphic model. +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * a random walk + +% Devin Sullivan +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D30' ); +warning('This demo is deprecated. The demo will be removed in future versions of CellOrganizer'); +disp( 'The estimated running time is 2 hours 30 minutes. Please wait.' ); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +scriptpath = pwd; +[path,scriptname,ext]=fileparts(mfilename); + +load('../../../models/3D/diffeomorphic/helamodel_9_16_15.mat') + +p = model.cellShapeModel.positions; + +rminds = any(isnan(p),2); + +pos = p(~rminds,1:2); + +c = 1; +gmmfitfile = 'gmmfit.mat'; +if ~exist(gmmfitfile, 'file') + objgmm = {}; + while c < 5 + tryagain = 0; + while tryagain < 2 + try + objgmm{c} = gmdistribution.fit(pos,c, 'replicates', 200); + break + catch + tryagain = tryagain + 1; + end + end + c = c+1; + end + save(gmmfitfile, 'objgmm') +else + load(gmmfitfile) +end + +[~, aicind] = min(cellfun(@(x) x.AIC, objgmm)); +[~, bicind] = min(cellfun(@(x) x.BIC, objgmm)); + +gmm_aic = objgmm{aicind}; +gmm_bic = objgmm{bicind}; + +tri = delaunay(pos); + +linx = linspace(min(pos(:,1)), max(pos(:,1)), 100); +liny = linspace(min(pos(:,2)), max(pos(:,2)), 100); + +[x,y] = meshgrid(linx,liny); + +for i = 1:length(x(:)) + gmm_pdf(i) = gmm_aic.pdf([x(i), y(i)]); +end + +figure('color', 'w') +axis('tight') + +scatter(x(:), y(:), 300, gmm_pdf, '.') +hold on + +scatter(pos(:,1), pos(:,2), 300, '.', 'k') +triplot(tri, pos(:,1), pos(:,2), 'k') +saveas(gcf, 'gmmdemo.png', 'png') + +positions = nan(size(model.cellShapeModel.positions,1),2); +positions(~rminds,:) = pos; + +embed_model = embed_distance_matrix([], struct('positions', model.cellShapeModel.positions(:,1:2))); + +model.cellShapeModel.positions = embed_model.positions; +model.nuclearShapeModel.positions = embed_model.positions; +model.cellShapeModel.tessellation = embed_model.tessellation; +model.nuclearShapeModel.tessellation = embed_model.tessellation; + +numimgs = 5; +for i = 1:numimgs + %sample from the gmm ANDed to the convex hull of the triangulation + simplex_idx = nan; + while isnan(simplex_idx) + point = gmm_aic.random; + simplex_idx = tsearchn(model.cellShapeModel.positions,model.cellShapeModel.tessellation,point); + end + points(i,:) = point; + + param.position = point; + + + savedir = [scriptpath filesep '_img' num2str(i)]; + if ~exist(savedir, 'dir') + mkdir(savedir) + end + cd(savedir); + + param.targetDirectory = [scriptpath filesep scriptname filesep 'img' num2str(i)]; + + imgs{i} = model2img({model}, param); +end + +answer = true; +end diff --git a/demos/3D/demo3D31/demo3D31.m b/demos/3D/demo3D31/demo3D31.m new file mode 100644 index 0000000..d9176f6 --- /dev/null +++ b/demos/3D/demo3D31/demo3D31.m @@ -0,0 +1,156 @@ +function answer = demo3D31() +% demo3D31 +% +% Trains a generative model of microtubules +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid model + +% Ivan E. Cao-Berg & Gregory R. Johnson +% +% Copyright (C) 2014-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo3D31' ); +disp( 'The estimated running time is greater than 12 hours. Please be patient.' ); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +pattern = 'Tub'; +imgdir = '../../../images/HeLa/3D/raw'; +options.protein.class = 'network'; +options.protein.type = 'microtubule_growth'; +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.type = 'cylindrical_surface'; +options.cell.class = 'cell_membrane'; +options.cell.type = 'ratio'; +options.protein.name = 'Tub'; +options.nucleus.name = 'Tub'; +options.cell.model = 'Tub'; +options.faster = false; +options.train.flag = 'all'; + +dimensionality = '3D'; +dna = [imgdir filesep 'Tub*cell*ch0*.tif'] ; +cell = [imgdir filesep 'Tub*cell*ch1*.tif']; +protein = [imgdir filesep 'Tub*cell*ch2*.tif']; +mask = [imgdir filesep 'Tub*cell*mask*.tif']; + +% generic model options +% --------------------- +options.model.name = 'microtubule_growth'; +options.model.id = num2str(now); +options.model.filename = [ lower(pattern) '.xml' ]; + +% nuclear shape model options +% --------------------------- +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.type = 'cylindrical_surface'; +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +options.cell.class = 'cell_membrane'; +options.cell.type = 'ratio'; +options.cell.id = num2str(now); + +% protein shape model options +% --------------------------- +options.protein.class = 'network'; +options.protein.type = 'microtubule_growth'; +options.protein.id = num2str(now); + +% other options +% ------------- +options.verbose = true; + +options.debug = true; +%options.train.flag = 'microtubule'; +options.model.resolution = [0.049, 0.049, 0.2000]; +options.downsampling = [4,4,1]; +options.saveIntermediateResults = false; +options.model.microtubule.searchparams.n = [50:100:500]; +options.model.microtubule.searchparams.mulen = [10:10:50]; +options.model.microtubule.searchparams.colli_min_number = [0.97, 1 ]; +options.protein.cytonuclearflag = 'cyto'; +options.debug = true; +options.verbose = true; + +dna_paths = dir(dna); +dna_paths = sort_nat({dna_paths.name}); + +prot_paths = dir(protein); +prot_paths = sort_nat({prot_paths.name}); + +cell_paths = dir(cell); +cell_paths = sort_nat({cell_paths.name}); + +mask_paths = dir(mask); +mask_paths = sort_nat({mask_paths.name}); + +for i = 1:length(dna_paths) + cell_imgs{i} = @() seg_hela([imgdir filesep cell_paths{i}], [imgdir filesep mask_paths{i}]); + dna_imgs{i} = @() seg_hela([imgdir filesep dna_paths{i}], [imgdir filesep mask_paths{i}]); + prot_imgs{i} = [imgdir filesep prot_paths{i}]; +end + +if ~exist([pwd filesep 'tub.mat'], 'file') + answer = img2slml( dimensionality, dna_imgs, cell_imgs, prot_imgs, options ); +else + answer = true; +end +end%demo3D31 + +function [ seg_region ] = seg_hela( impath, maskpath ) +%SEG_HELA Summary of this function goes here +% Detailed explanation goes here +img = ml_readimage(impath); +mask = ml_readimage(maskpath); +mask = mask(:,:,1); +mask = repmat(mask, [1,1, size(img,3)]) > 0; +img = mat2gray(img); +img_region = img > graythresh(img); +img_region = img_region.*mask; +regions = bwconncomp(img_region); +[~, ind] = max(cellfun(@(x) size(x,1), regions.PixelIdxList)); +seg_region = false(size(img)); +seg_region(regions.PixelIdxList{ind}) = true; +seg_region = imfill(seg_region, 'holes'); +end%seg_hela diff --git a/demos/3D/demo3D32/demo3D32.m b/demos/3D/demo3D32/demo3D32.m new file mode 100755 index 0000000..1de7a52 --- /dev/null +++ b/demos/3D/demo3D32/demo3D32.m @@ -0,0 +1,82 @@ +function answer = demo3D32() +% demo3D32 +% +% Synthesizes 1 image using a lysosomal model with sampling mode +% set to 'disc', no convolution using the object avoidance methods +% Results will be three TIFF files, one each for cell boundary, +% nuclear boundary, and lysosomes, in folder "synthesizedImages/cell1". +% +% Input +% ----- +% * valid SBML file +% +% Output +% ------ +% * three TIFF files + +% Devin Sullivan +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D32' ); +disp( 'The estimated running time is 2 minutes 30 seconds. Please wait.' ); + +answer = false; + +options.seed = 3; +try + state = rng(options.seed); +catch + state = RandStream.create('mt19937ar','seed',options.seed); + RandStream.setGlobalStream(state); +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.numberOfSynthesizedImages = 1; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.blenderfile = true; +options.output.blender.downsample = 5; +options.numberOfGaussianObjects = 25; +options.output.tifimages = true; +options.overlapsubsize = 1; +options.overlapthresh = 1; +options.rendAtStd = 1; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +slml2img( {'../../../models/3D/lamp2.mat'}, options ); +answer = true; +end%demo3D32 diff --git a/demos/3D/demo3D32/perobjmdl.m b/demos/3D/demo3D32/perobjmdl.m new file mode 100644 index 0000000..ea0e563 --- /dev/null +++ b/demos/3D/demo3D32/perobjmdl.m @@ -0,0 +1,38 @@ +function perobjmdl(savepath,resolution) +%This function saves .mdl files for simulating object meshes in MCell. +%currently it saves a single .mdl file for each endosome with only size +%data. +% +%Inputs: +%savepath = string pointing to the desired folder to save the .mdl files +% +%Outputs: +%set of .mdl files +% +%Author: Devin Sullivan July 23, 2013 +mkdir(savepath) + +if isempty(resolution) + resolution = [1,1,1]; +end + +%first load temp results +load([pwd filesep 'temp' filesep 'primitives']); +load([pwd filesep 'temp' filesep 'OriginalObjects.mat']); +% 'GaussObjects','pos'); +% objsizevec = objsizevec.*repmat(resolution,[size(objsizevec,1),1]); + + +%Create an image for each object +for i = 1:size(objsizevec,1) + %initialize image to zeros + img = zeros(ceil(objsizevec(i,1)),ceil(objsizevec(i,2)),ceil(objsizevec(i,3))); + %put objects into image + protimg = ml_imaddobj2(blankimg,GaussObjects,... + struct('method','replace','pos',newpos,'objectmethod',param.sampling.method)); + + + +end + + diff --git a/demos/3D/demo3D33/demo3D33.m b/demos/3D/demo3D33/demo3D33.m new file mode 100644 index 0000000..8cf2d16 --- /dev/null +++ b/demos/3D/demo3D33/demo3D33.m @@ -0,0 +1,93 @@ +function answer = demo3D33() +% demo3D33 +% +% Synthesize multiple 3D images from a lysosome model, at different resolutions. +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------- +% * multiple instances of the same cell at different resolutions + +% Gregory R. Johnson +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +% July 21, 2012 R.F. Murphy Additional documentation. +% August 10, 2012 I. Cao-Berg Reflected changes from img2projection + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D33' ); +disp( 'The estimated running time is 30 seconds. Please wait.' ); + +options.seed = 1245; +options.targetDirectory = pwd; +options.numberOfSynthesizedImages = 1; +options.image.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.overlapthresh = 0; %to make the synthesis go very fast +options.prefix = 'imres1'; +options.outputres = 1; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +try + state = rng(options.seed); +catch + state = RandStream.create('mt19937ar','seed',options.seed); + RandStream.setGlobalStream(state); +end + +if ~exist( [ pwd filesep 'imres1/cell1/cell.tif' ], 'file' ) + slml2img( {'../../../models/3D/lamp2.mat'}, options ); +else + disp('Image exists on disk. Skipping synthesis.'); +end + +options.prefix = 'imres2'; +options.outputres = 0.50; + +try + state = rng(options.seed); +catch + state = RandStream.create('mt19937ar','seed',options.seed); + RandStream.setDefaultStream(state); +end +if ~exist( [ pwd filesep 'imres2/cell1/cell.tif'], 'file' ) + answer = slml2img( {'../../../models/3D/lamp2.mat'}, options ); +else + disp('Image exists on disk. Skipping synthesis.'); + answer = 1; +end diff --git a/demos/3D/demo3D34/demo3D34.m b/demos/3D/demo3D34/demo3D34.m new file mode 100644 index 0000000..513159f --- /dev/null +++ b/demos/3D/demo3D34/demo3D34.m @@ -0,0 +1,100 @@ +function answer = demo3D34( options ) +% demo3D34 +% +% Synthesize one 3D image with nuclear, cell shape and a vesicular channel. +% This demo exports the synthetic image as an OME.TIFF as well as an +% SBML Spatial instance. +% +% Input +% ----- +% * a valid CellOrganizer model +% +% Output +% ------ +% * OME.TIFF +% * SBML instance +% * single channel TIF files + +% Ivan E. Cao-Berg +% +% Copyright (C) 2016-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +start_time = tic; +start_cputime = cputime; + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D34' ); +disp( 'The estimated running time is about 31 minutes. Please wait.' ); + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.numberOfSynthesizedImages = 1; +options.numberOfGaussianObjects = 25; +options.prefix = 'img'; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.tifimages = true; +options.overwrite_synthetic_instances = false; +options.rendAtStd = 1.0; +options.objstd = options.rendAtStd+0.3; +options.overlapsubsize = 1; +options.output.SBMLSpatial = true; +options.output.OMETIFF = true; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +% note, the framework will be synthesized using the first protein model +% found to match the given patterns in the SBML file. +% Changing the order/priority of this is not supported at this time. +list_of_models = {'../../../models/3D/tfr.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); + +% validate_SBML_instance is not working +% [sbml_valid, sbml_problems] = validate_SBML_instance('./img/cell1/cell.xml', true) + +elapsed_time = toc(start_time); +elapsed_cputime = cputime - start_cputime; +fprintf('\n%s took %.3f s (%.3f s CPU time)\n\n', mfilename, elapsed_time, elapsed_cputime); + +end%demo3D34 diff --git a/demos/3D/demo3D35/demo3D35.m b/demos/3D/demo3D35/demo3D35.m new file mode 100755 index 0000000..c9a8d41 --- /dev/null +++ b/demos/3D/demo3D35/demo3D35.m @@ -0,0 +1,58 @@ +function answer = demo3D35() +% demo3D35 +% +% This demo uses slml2model to display information from a valid model file +% +% Input +% ----- +% * a CellOrganizer model +% +% Output +% ------ +% * a report + +% Ivan E. Cao-Berg +% +% Copyright (C) 2018-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D35' ); +disp( 'The estimated running time is 1 minute. Please wait.' ); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +directory = '../../../models/3D/diffeomorphic/'; +instance = {[directory filesep 'helamodel_9_16_15.mat']}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2info(instance); +end%demo3D47 diff --git a/demos/3D/demo3D36/demo3D36.m b/demos/3D/demo3D36/demo3D36.m new file mode 100644 index 0000000..af77d74 --- /dev/null +++ b/demos/3D/demo3D36/demo3D36.m @@ -0,0 +1,107 @@ +function answer = demo3D36() +% demo3D36 +% +% Synthesize multiple 3D images from a lysosome model at different resolutions. +% +% Input +% ----- +% * valid lysosomal model +% +% Output +% ------ +% * multiple 3D images at different resolutions + +% Gregory R. Johnson +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +% July 21, 2012 R.F. Murphy Additional documentation. +% August 10, 2012 I. Cao-Berg Reflected changes from img2projection + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +answer = false; +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +options.seed = 3; +options.targetDirectory = pwd; +options.numberOfSynthesizedImages = 1; +options.image.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.overlapthresh = 0; %to make the synthesis go very fast +options.prefix = 'imres1'; +options.outputres = 1; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +try + state = rng(options.seed); +catch + state = RandStream.create('mt19937ar','seed',options.seed); + RandStream.setDefaultStream(state); +end + +if ~exist( [ pwd filesep 'imres1/cell1/cell.tif'], 'file' ) + slml2img( {'../../../models/3D/lamp2.mat'}, options ); +else + disp('Image exists on disk. Skipping synthesis.'); +end + +options.prefix = 'imres2'; +options.outputres = 1; + +try + state = rng(options.seed); +catch + state = RandStream.create('mt19937ar','seed',options.seed); + RandStream.setDefaultStream(state); +end +if ~exist( [ pwd filesep 'imres2/cell1/cell.tif'], 'file' ) + slml2img( {'../../../models/3D/lamp2.mat'}, options ); +else + disp('Image exists on disk. Skipping synthesis.'); +end + +options.prefix = 'imres3'; +options.outputres = 1; + +try + state = rng(options.seed); +catch + state = RandStream.create('mt19937ar','seed',options.seed); + RandStream.setGlobalStream(state); +end + +if ~exist( [ pwd filesep 'imres3/cell1/cell.tif'], 'file' ) + slml2img( {'../../../models/3D/lamp2.mat'}, options ); +else + disp('Image exists on disk. Skipping synthesis.'); +end +answer = true; +end diff --git a/demos/3D/demo3D37/demo3D37.m b/demos/3D/demo3D37/demo3D37.m new file mode 100644 index 0000000..b34cf34 --- /dev/null +++ b/demos/3D/demo3D37/demo3D37.m @@ -0,0 +1,114 @@ +function answer = demo3D37(options) +% demo3D37 +% +% This demo exists to illustrate how padding size and window size affect the +% performance of diffeomorphic metric. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * a directory of raw or synthetic lysosome images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------- +% * a valid SLML model file + +% Copyright (C) 2012-2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University + +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +answer = false; +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Generate some superellipses: + generate_options = struct(); + % Set this: + generate_options.number_images = 3; + generate_options.minimum_relative_semidiameter = 1 / 4; + generate_options.maximum_relative_semidiameter = 2 / 3; + generate_options.generate_cycle = true; + % Set this: + generate_options.image_width = 128; + + [shapes, shape_parameters] = generate_superellipse_shape_set(generate_options); + + options = struct(); + +% nucleus.id (optional) Holds the id of the nuclear model. Default is empty. +options.nucleus.type = 'diffeomorphic'; +options.nucleus.class = 'framework'; +options.cell.type = 'diffeomorphic'; +options.cell.class = 'framework'; +options.protein.class = 'vesicle'; +options.protein.type = 'gmm'; + +options.verbose = true; +options.debug = true; + +% train.flag (optional) Selects what model is going to be trained ('nuclear', +% 'framework', or 'all'). Default is 'all' +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.model.resolution = [1,1,1]; + +options.model.filename = mfilename; + +options.downsampling = [1,1,1]; + +options.tempparent = [pwd filesep 'temp' filesep]; + +%documentation +options.documentation.description = 'This model has been trained using demo3D37 from CellOrganizer'; + +for i = 1:length(shapes) + objimg{i} = @() shapes{i} > 0; +end + +imfunc = @(x) double(shapes{x} > 0); + +windowradii = 128./[1,2,4,8,16]; + +for i = 1:length(windowradii) + filename = ['diffeomorphic_wr' num2str(windowradii(i))]; + + options.model.filename = filename; + options.model.diffeomorphic.window_radius = windowradii(i); + options.model.diffeomorphic.image_function = imfunc; + + options.model.diffeomorphic.tempdir = [options.tempparent filesep filename]; + tic + success = img2slml( '3D', objimg, objimg, [], options ); + timer(i) = toc; +end + +answer = true; +end%demo3D37 diff --git a/demos/3D/demo3D38/demo3D38.m b/demos/3D/demo3D38/demo3D38.m new file mode 100755 index 0000000..f551834 --- /dev/null +++ b/demos/3D/demo3D38/demo3D38.m @@ -0,0 +1,77 @@ +function answer = demo3D38() +% demo3D38 +% +% Synthesizes 1 image using a lysosomal model with sampling mode +% set to 'disc', no convolution using the object avoidance methods +% Results will be three TIFF files, one each for cell boundary, +% nuclear boundary, and lysosomes, in folder "synthesizedImages/cell1". +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * three TIFF files (nuclear, cell shape, and nucleolar channels) + +% Devin Sullivan +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +answer = false; +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +options.seed = 3; +try + state = rng(options.seed); +catch + state = RandStream.create('mt19937ar','seed',options.seed); + RandStream.setGlobalStream(state); +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.numberOfSynthesizedImages = 1; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.blenderfile = true; +options.output.blender.downsample = 5; +options.output.tifimages = true; +options.numberOfGaussianObjects = 5; +options.overlapsubsize = 1; +options.overlapthresh = 1; +options.rendAtStd = 1; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( {'../../../models/3D/lamp2.mat'}, options ); +end%demo3D38 diff --git a/demos/3D/demo3D38/perobjmdl.m b/demos/3D/demo3D38/perobjmdl.m new file mode 100644 index 0000000..ea0e563 --- /dev/null +++ b/demos/3D/demo3D38/perobjmdl.m @@ -0,0 +1,38 @@ +function perobjmdl(savepath,resolution) +%This function saves .mdl files for simulating object meshes in MCell. +%currently it saves a single .mdl file for each endosome with only size +%data. +% +%Inputs: +%savepath = string pointing to the desired folder to save the .mdl files +% +%Outputs: +%set of .mdl files +% +%Author: Devin Sullivan July 23, 2013 +mkdir(savepath) + +if isempty(resolution) + resolution = [1,1,1]; +end + +%first load temp results +load([pwd filesep 'temp' filesep 'primitives']); +load([pwd filesep 'temp' filesep 'OriginalObjects.mat']); +% 'GaussObjects','pos'); +% objsizevec = objsizevec.*repmat(resolution,[size(objsizevec,1),1]); + + +%Create an image for each object +for i = 1:size(objsizevec,1) + %initialize image to zeros + img = zeros(ceil(objsizevec(i,1)),ceil(objsizevec(i,2)),ceil(objsizevec(i,3))); + %put objects into image + protimg = ml_imaddobj2(blankimg,GaussObjects,... + struct('method','replace','pos',newpos,'objectmethod',param.sampling.method)); + + + +end + + diff --git a/demos/3D/demo3D39/demo3D39.m b/demos/3D/demo3D39/demo3D39.m new file mode 100644 index 0000000..a542e72 --- /dev/null +++ b/demos/3D/demo3D39/demo3D39.m @@ -0,0 +1,97 @@ +function answer = demo3D39() +% demo3D39 +% +% This demo illustrates how to sample uniformly at random from a +% diffeomorphic model. +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * a random walk + +% Devin Sullivan +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp('demo3D39'); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +options.targetDirectory = pwd; +scriptpath = pwd; +scriptname = mfilename; + +model_filename = '../../../models/3D/diffeomorphic/helamodel_9_16_15.mat'; +if exist( model_filename ) + load(model_filename ) + + cellinds = find(all(~isnan(model.cellShapeModel.positions),2)); + positions = model.cellShapeModel.positions(cellinds,:); + + minpos = min(positions,[],1); + maxpos = max(positions,[],1); + + numimgs = 5; + for i = 1:numimgs %this may take a few seconds, and of course will take long the greater the dimensionality of the space + %sample from the uniform distribution ANDed to the convex hull of the triangulation + simplex_idx = nan; + + while isnan(simplex_idx) + point = rand([1, size(minpos,2)]).*(maxpos - minpos) + minpos; + simplex_idx = tsearchn( model.cellShapeModel.positions, ... + model.cellShapeModel.tessellation, point ); + end + + points(i,:) = point; + + options.position = point; + savedir = [scriptpath filesep '_img' num2str(i)]; + if ~exist(savedir, 'dir') + mkdir(savedir) + end + + cd(savedir); + + options.targetDirectory = [scriptname filesep 'img' num2str(i)]; + options.synthesis.flag = 'framework'; + + imgs{i} = model2img( {model}, options ); + end + + answer = true; +else + warning(['Model filename ' model_filename ' does not exist.']); + answer = false; + return +end \ No newline at end of file diff --git a/demos/3D/demo3D40/demo3D40.m b/demos/3D/demo3D40/demo3D40.m new file mode 100755 index 0000000..3cb80fd --- /dev/null +++ b/demos/3D/demo3D40/demo3D40.m @@ -0,0 +1,133 @@ +function answer = demo3D40(options) +% demo3D40 +% +% Train 3D generative framework model from all LAMP2 images in the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * a directory of raw or synthetic lysosome images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Xin Lu +% +% Copyright (C) 2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +answer = false; +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D40' ); +disp( 'The estimated running time is 12 minutes. Please wait.' ); + +pattern = 'LAMP2'; +dimensionality = '3D'; +options.protein.class = 'lysosome'; +options.protein.name = 'lamp2'; +options.nucleus.name = 'lamp2'; +options.cell.model = 'lamp2'; + +% generic model options +% --------------------- +options.model.name = 'framework'; +options.model.id = num2str(now); + +% nuclear shape model options +% --------------------------- +% nucleus.type Holds the nuclear model type. Default is "cylindrical_surface". +options.nucleus.type = 'cylindrical_surface'; +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +options.cell.type = 'ratio'; +options.cell.id = num2str(now); +options.cell.class = 'cell_membrane'; + +% protein.cytonuclearflag (optional) Determines whether the protein pattern will be generated in +% the cytosolic space ('cyto'), nuclear space ('nuc') or everywhere ('all'). +% Default is cyto. +if strcmpi( options.protein.class, 'nuc' ) + options.protein.cytonuclearflag = 'nuc'; +else + options.protein.cytonuclearflag = 'cyto'; +end + +% other options +% ------------- +options.verbose = true; +options.debug = false; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); + +% documentation +% ------------- +options.documentation.description='This model has been trained using demo3D40 from CellOrganizer'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +directory = '../../../images/HeLa/3D/ometiff'; + +if ~exist( directory ) + warning(['Directory ' directory ' does not exist. Exiting demo.']); + return +else + files = dir([directory filesep '3D_HeLa_LAMP2*.ome.tif']); + files = sort_nat({files.name}); + + for i = 1:10 + masks{i} = @() flipdim( OME_loadchannel( ... + [directory filesep files{i}],1),3 ); + dna{i} = @() flipdim( OME_loadchannel( ... + [directory filesep files{i}],2),3 ); + cell{i} = @() flipdim( OME_loadchannel( ... + [directory filesep files{i}],3),3 ); + end + + if isempty( masks ) || isempty( dna ) || isempty( cell ) + warning('One or several list of image files is/are empty. Exiting demo'); + return + end + + options.model.resolution=[0.049, 0.049, 0.2000]; + options.downsampling = [5,5,1]; + options.model.filename = 'model.xml'; + options.masks = masks; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + answer = img2slml( dimensionality, dna, cell, [], options ); +end diff --git a/demos/3D/demo3D41/demo3D41.m b/demos/3D/demo3D41/demo3D41.m new file mode 100644 index 0000000..a996982 --- /dev/null +++ b/demos/3D/demo3D41/demo3D41.m @@ -0,0 +1,147 @@ +function answer = demo3D41(options) +% demo3D41 +% +% Train 3D generative model of the nucleus, cell shape, and lysosome from +% all LAMP2 images in the Murphy Lab 3D HeLa dataset that are either in the +% current directory or in the demo3D11 directory. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * a directory of raw or synthetic lysosome images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Xin Lu +% +% Copyright (C) 2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +answer = false; +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D41' ); +disp( 'The estimated running time is 12 minutes. Please wait.' ); + +pattern = 'LAMP2'; +dimensionality = '3D'; +options.protein.class = 'lysosome'; +options.protein.name = 'lamp2'; +options.nucleus.name = 'lamp2'; +options.cell.model = 'lamp2'; + +% generic model options +% --------------------- +options.model.name = 'all'; +options.model.id = num2str(now); + +% nuclear shape model options +% --------------------------- +% nucleus.type Holds the nuclear model type. Default is "cylindrical_surface". +options.nucleus.type = 'cylindrical_surface'; +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +options.cell.type = 'ratio'; +options.cell.id = num2str(now); +options.cell.class = 'cell_membrane'; + +% protein shape model options +% --------------------------- +% protein.type (optional) Holds the protein model type. The default is "vesicle". +options.protein.type = 'gmm'; +options.protein.class = 'vesicle'; +options.protein.id = num2str(now); + +% protein.cytonuclearflag (optional) Determines whether the protein pattern will be generated in +% the cytosolic space ('cyto'), nuclear space ('nuc') or everywhere ('all'). +% Default is cyto. +if strcmpi( options.protein.class, 'nuc' ) + options.protein.cytonuclearflag = 'nuc'; +else + options.protein.cytonuclearflag = 'cyto'; +end + +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'all' ))); +% other options +% ------------- +options.verbose = true; +options.debug = false; + +% documentation +% ------------- +options.documentation.description='This model has been trained using demo3D41 from CellOrganizer'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +directory = '../../../images/HeLa/3D/ometiff'; + +if ~exist( directory ) + warning(['Directory ' directory ' does not exist. Exiting demo.']); + return +else + files = dir([directory filesep '3D_HeLa_LAMP2*.ome.tif']); + files = sort_nat({files.name}); + + masks = {}; dna = {}; cell = {}; protein = {}; options.labels = {}; + + for i = 1:10 + masks{i} = @() flipdim( OME_loadchannel( ... + [directory filesep files{i}],1),3 ); + dna{i} = @() flipdim( OME_loadchannel( ... + [directory filesep files{i}],2),3 ); + cell{i} = @() flipdim( OME_loadchannel( ... + [directory filesep files{i}],3),3 ); + protein{i} = @() flipdim( OME_loadchannel( ... + [directory filesep files{i}],4),3 ); + options.labels{i} = 'LAMP2'; + end + + if isempty( masks ) || isempty( dna ) || isempty( cell ) || ... + isempty( protein ) + warning('One or several list of image files is/are empty. Exiting demo'); + return + end + + options.model.resolution=[0.049, 0.049, 0.2000]; + options.downsampling = [5,5,1]; + options.model.filename = 'model.xml'; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + answer = img2slml( dimensionality, dna, cell, protein, options ); +end diff --git a/demos/3D/demo3D42/demo3D42.m b/demos/3D/demo3D42/demo3D42.m new file mode 100644 index 0000000..158a425 --- /dev/null +++ b/demos/3D/demo3D42/demo3D42.m @@ -0,0 +1,120 @@ +function answer = demo3D42() +% demo3D42 +% +% This demo illustrates using CellOrganizer to train a protein distribution +% model following the approach described in +% +% K. T. Roybal, T. E. Buck, X. Ruan, B. H. Cho, D. J. Clark, R. Ambler, +% H. M. Tunbridge, J. Zhang, P. Verkade, C. Wülfing, and R. F. Murphy (2016) +% Computational spatiotemporal analysis identifies WAVE2 and Cofilin as +% joint regulators of costimulation-mediated T cell actin dynamics. +% Science Signaling 9:rs3. doi: 10.1126/scisignal.aad4149. +% +% The slowest step, which typically takes about 1 min per cell per frame, +% is to align each cell at each time to the standardized template. +% This demo uses 46 cells so it will take about 1 hour on a single core. +% +% Input +% ----- +% * image and annotation files for one or more proteins for one or more +% time points (the default is to use images from the paper of LAT at time 0 +% - downloading the needed images requires about 4 GB of free disk space) +% +% Output +% ------ +% * a model for the average concentration in each voxel of a standardized +% cell shape (in demos/LAT_reltime_1.mat) +% * various intermediate results files (in /param and /tmp) + +% Xiongtao Ruan +% +% Copyright (C) 2016-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +% set up intermediate result location +results_location = './models'; + +% set up synapse location +synapse_location = {'../../../images/LAT/annotations/*.csv'}; + +% options.image_location = image_location; +options.model.tcell.synapse_location = synapse_location; + +options.results_location = results_location; +% the running choice for cellorganizer and one sensor of two-point annotation. +options.model.tcell.named_options_set = 'cellorganizer_one_sensor_2pt'; + +% set up the mode of synapse to use, as a default, we use one-point, if +% needed you can use two-point by set up the option as true +options.model.tcell.use_two_point_synapses = true; + +% set up protein name +options.model.tcell.sensor = 'LAT'; + +% set up which time points need to analyze +options.model.tcell.timepoints_to_include = [0]; + +% set up condition +% options.model.tcell.conditions_to_include = {'Full Stimulus'}; +options.model.tcell.model_type_to_include = {'standardized_voxels'}; +options.model.resolution = [0.049, 0.049, 0.2000]; + +options.train.flag = 'protein'; + +% set up protein model type +options.protein.class = 'standardized_voxels'; +options.protein.type = 'standardized_map_half-ellipsoid'; + +options.train.flag = 'protein'; + +% set up model name +options.model_prefix = 'LAT_'; + +options.model.tcell.ometiff = false; +% model.id (optional) Holds the id of the model. Default is empty. + +try + [status, result] = system( 'uuidgen' ); + options.model.id = result(1:end-1); +catch + options.model.id = num2str(now); +end + +% set up model filename +options.model.filename = 'model.xml'; + +options.debug = true; +options.verbose = true; + +dimensionality = '3D'; +options.dimensionality = dimensionality; + +answer = img2slml(dimensionality, {}, {}, {}, options); +end%demo3D42 diff --git a/demos/3D/demo3D43/demo3D43.m b/demos/3D/demo3D43/demo3D43.m new file mode 100644 index 0000000..61ca499 --- /dev/null +++ b/demos/3D/demo3D43/demo3D43.m @@ -0,0 +1,153 @@ +function answer = demo3D43() +% demo3D43 +% +% This is the synthesis demo for T cell model. +% The demo takes in two models: one model contains both cell and nuclear +% shape models, and the other contains a T cell protein shape model. Same +% as other synthesis framework, it calls slml2img for the synthesis. The +% meanings of the options are commented in the script. +% +% Input +% ----- +% * A protein model with type standardized map halp-elipsoid +% * A framework model the provide the shape of the cell. +% +% Output +% ------ +% * one or more set(s) of synthesized images with cell shape and protein +% pattern. + +% Xiongtao Ruan +% +% Copyright (C) 2016-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +% set up intermediate result location +results_location = './models'; + +options.results_location = results_location; +% set up the mode of synapse to use, as a default, we use one-point, if +% needed you can use two-point by set up the option as true +options.model.tcell.use_two_point_synapses = true; + +% set up protein name +% options.model.tcell.sensor = 'Actin'; + +% set up which time points need to analyze +options.model.tcell.timepoints_to_include = [0]; + +% set up condition +% options.model.tcell.conditions_to_include = {'Full Stimulus'}; +options.model.tcell.model_type_to_include = {'standardized_voxels'}; +options.model.resolution = [0.049, 0.049, 0.2000]; + +% set up protein model type +options.protein.type = 'morphing'; + +% set up model name +options.model_prefix = 'LAT_'; +% model.id (optional) Holds the id of the model. Default is empty. + +try + [status, result] = system( 'uuidgen' ); + options.model.id = result(1:end-1); +catch + options.model.id = num2str(now); +end + +options.model.filename = [ options.model.tcell.model_type_to_include{1}, '.xml' ]; + +options.debug = false; + +dimensionality = '3D'; +options.dimensionality = dimensionality; +% cd('../tcell_clean'); +current_path = which(mfilename); +[current_path, filename, extension] = fileparts( current_path ); +cd(current_path); + +% random seeding +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +% set up output directory +options.targetDirectory = pwd; + +options.prefix = 'img'; +% set up compression method for the image +options.compression = 'lzw'; +% set up debug +options.debug = false; +% set up verbose +options.verbose = true; +% set up display +options.display = false; +% set up synthesis method +options.synthesis = 'all'; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% set up the input models +% we use a diffeomorphic model for cell and nuclear shape +model_1 = load('../../../models/3D/diffeomorphic/hela_cell_10_15_15.mat'); +%model_1 = load('hela_cell_10_15_15.mat'); +%T cell model +try + model_2 = load('../demo3D42/models/LAT_reltime_0.mat'); +catch + error('You must run demo3D42 first or download a model from the website') +end + +% merge two models +model_2.model.cellShapeModel = model_1.model.cellShapeModel; +model_2.model.nuclearShapeModel = model_1.model.nuclearShapeModel; +model = model_2.model; +% set up model type +model.proteinModel.type = 'standardized_map_half-ellipsoid'; +model.proteinModel.class = 'standardized_voxels'; +clear model_1 +clear model_2 + +save('model.mat', 'model'); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'./model.mat'}; + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +output = slml2img( list_of_models, options ); + + if (~isempty(output)) + answer = true; + else + answer = false; + end +end diff --git a/demos/3D/demo3D44/demo3D44.m b/demos/3D/demo3D44/demo3D44.m new file mode 100644 index 0000000..232a829 --- /dev/null +++ b/demos/3D/demo3D44/demo3D44.m @@ -0,0 +1,72 @@ +function answer = demo3D44() +% demo3D44 +% +% Synthesize a cell shape image from a given constructive_geometry model, +% specifically a half-ellipsoid model. +% +% Input +% ----- +% * a list of valid CellOrganizer half-ellipsoid model files +% +% Output +% ------ +% * a 3D stacked TIFF file + +% Xin Lu, Nicole Matamala and Xiongtao Ruan +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.sampling.method = 'disc'; +options.debug = false; +options.verbose = true; +options.display = false; +options.numberOfGaussianObjects = 25; +options.synthesis = 'framework'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +list_of_models = {'../../../models/3D/csgo/ellipsoid_model.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); \ No newline at end of file diff --git a/demos/3D/demo3D45/demo3D45.m b/demos/3D/demo3D45/demo3D45.m new file mode 100755 index 0000000..f0bf46c --- /dev/null +++ b/demos/3D/demo3D45/demo3D45.m @@ -0,0 +1,122 @@ +function answer = demo3D45(options) +% demo3D45 +% +% Train 3D generative model of the cell framework (nucleus and cell shape) +% using the Murphy Lab 3D HeLa TfR dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid model + +% Xin Lu +% +% Copyright (C) 2012-2017 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +disp( 'demo3D45' ); +disp( 'The estimated running time is 20 minutes. Please wait.' ); + +options.sampling.method = 'disc'; +options.debug = true; +options.verbose = true; +options.display = false; + +options.downsampling = [5,5,1]; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.model.filename = 'model.xml'; + +% generic model options +% --------------------- +options.model.name = '3d_hela_framework_model'; +options.model.id = num2str(now); + +% nuclear shape model options +% --------------------------- +options.nucleus.type = 'cylindrical_surface'; +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.name = 'all'; +options.nucleus.id = num2str(now); + +% cell shape model options +% ------------------------ +options.cell.type = 'ratio'; +options.cell.class = 'cell_membrane'; +options.cell.model = 'framework'; +options.cell.id = num2str(now); + +options.protein.type = 'gmm'; +options.protein.class = 'vesicle'; +% options.protein.model = 'framework'; +options.protein.id = num2str(now); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +options.model.resolution = [0.049, 0.049, 0.2000]; +imageDirectory = '../../../images/HeLa/3D/processed/'; + +dimensionality = '3D'; +pattern = 'framework'; + +% dna = [imageDirectory filesep 'TfR*cell*ch0*.tif']; +% cell = [imageDirectory filesep 'TfR*cell*ch1*.tif']; +% options.masks = [imageDirectory filesep 'TfR*mask*.tif']; + +directory = '../../../images/HeLa/3D/ometiff_with_rois'; +if ~exist( directory ) + answer = false; + warning(['Folder ' directory ' does not exist. Exiting demo.']); + return +end + +dna = get_list_of_function_handles_from_wildcards([ directory filesep '/*.ome.tif'], 1); +cell = get_list_of_function_handles_from_wildcards([ directory filesep '/*.ome.tif'], 2); + +% documentation +% ------------- +options.documentation.author = 'Murphy Lab'; +options.documentation.email = 'murphy@cmu.edu'; +options.documentation.website = 'murphy@cmu.edu'; +options.documentation.description = 'This is the framework model is the result from demo3D45.'; +options.documentation.date = date; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = img2slml( dimensionality, dna, cell, [], options ); +end%demo3D45 \ No newline at end of file diff --git a/demos/3D/demo3D46/demo3D46.m b/demos/3D/demo3D46/demo3D46.m new file mode 100644 index 0000000..4e1ef45 --- /dev/null +++ b/demos/3D/demo3D46/demo3D46.m @@ -0,0 +1,147 @@ +function answer = demo3D46() +% demo3D46 +% +% This is the synthesis demo for T cell model. +% The demo takes in two models: one model contains both cell and nuclear +% shape models, and the other contains a T cell protein shape model. Same +% as other synthesis framework, it calls slml2img for the synthesis. The +% meanings of the options are commented in the script. +% +% Input +% ----- +% * A protein model with type standardized map halp-elipsoid +% * A framework model the provide the shape of the cell. +% +% Output +% ------ +% * one or more set(s) of synthesized images with cell shape and protein +% pattern. + +% Xiongtao Ruan +% +% Copyright (C) 2016-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +% set up intermediate result location +results_location = './models'; + +options.results_location = results_location; +% set up the mode of synapse to use, as a default, we use one-point, if +% needed you can use two-point by set up the option as true +options.use_two_point_synapses = true; + +% set up protein name +% options.sensor = 'Actin'; + +% set up which time points need to analyze +options.timepoints_to_include = [0]; + +% set up condition +% options.conditions_to_include = {'Full Stimulus'}; +options.model_type_to_include = {'standardized_voxels'}; +options.model.resolution = [0.049, 0.049, 0.2000]; + +% set up protein model type +options.protein.type = 'morphing'; + +% set up model name +options.model_prefix = 'LAT_'; +% model.id (optional) Holds the id of the model. Default is empty. + +try + [status, result] = system( 'uuidgen' ); + options.model.id = result(1:end-1); +catch + options.model.id = num2str(now); +end + +options.model.filename = [ options.model_type_to_include{1}, '.xml' ]; + +options.debug = false; + +dimensionality = '3D'; +options.dimensionality = dimensionality; +% cd('../tcell_clean'); +current_path = which(mfilename); +[current_path, filename, extension] = fileparts( current_path ); +cd(current_path); + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% random seeding +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +% set up output directory +options.targetDirectory = pwd; + +options.prefix = 'img'; +% set up compression method for the image +options.compression = 'lzw'; +% set up debug +options.debug = false; +% set up verbose +options.verbose = true; +% set up display +options.display = false; +% set up synthesis method +options.synthesis = 'all'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +% set up the input models +% we use a diffeomorphic model for cell and nuclear shape +model_1 = load('../../../models/3D/csgo/ellipsoid_model.mat'); +%T cell model +try + model_2 = load('../demo3D42/models/LAT_reltime_0.mat'); +catch + error('You must run demo3D42 first or download a model from the website') +end + +% merge two models +model_2.model.cellShapeModel = model_1.model.cellShapeModel; +model_2.model.nuclearShapeModel = model_1.model.nuclearShapeModel; +model = model_2.model; +% set up model type +model.proteinModel.type = 'standardized_map_half-ellipsoid'; +model.proteinModel.class = 'standardized_voxels'; +clear model_1 +clear model_2 + +save('model.mat', 'model'); +list_of_models = {'./model.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); +end%demo3D46 diff --git a/demos/3D/demo3D47/demo3D47.m b/demos/3D/demo3D47/demo3D47.m new file mode 100644 index 0000000..06fb57b --- /dev/null +++ b/demos/3D/demo3D47/demo3D47.m @@ -0,0 +1,76 @@ +function answer = demo3D47() +% demo3D47 +% +% Combine two generative model files into a single file. +% +% Input +% ----- +% * a list of valid CellOrganizer model files +% +% Output +% ------ +% * a valid model + +% Rita Chen +% +% Copyright (C) 2012-2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D47' ); +disp( 'The estimated running time is about 1 minutes. Please wait.' ); + +options.output_filename = 'model.mat'; +options.selection = [1,1,0;0,0,1]; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% documentation +% ------------- +options.documentation.author = 'Murphy Lab'; +options.documentation.email = 'murphy@cmu.edu'; +options.documentation.website = 'murphy@cmu.edu'; +options.documentation.description = 'This combined model is the result from demo3D47.'; +options.documentation.date = date; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +% note, the framework will be synthesized using the first protein model +% found to match the given patterns in the SBML file. +% Changing the order/priority of this is not supported at this time. +directory = "../../../models/3D/"; +file1 = strcat(directory,"mit.mat"); +file2 = strcat(directory,"nuc.mat"); +files = {file1, file2}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2slml(files,options); +end%demo3D47 diff --git a/demos/3D/demo3D48/demo3D48.m b/demos/3D/demo3D48/demo3D48.m new file mode 100644 index 0000000..5678e65 --- /dev/null +++ b/demos/3D/demo3D48/demo3D48.m @@ -0,0 +1,125 @@ +function answer = demo3D48() +% demo3D48 +% +% This demo illustrates using CellOrganizer to train an updated version of +% protein distribution model following the approach described in +% +% K. T. Roybal, T. E. Buck, X. Ruan, B. H. Cho, D. J. Clark, R. Ambler, +% H. M. Tunbridge, J. Zhang, P. Verkade, C. Wülfing, and R. F. Murphy (2016) +% Computational spatiotemporal analysis identifies WAVE2 and Cofilin as +% joint regulators of costimulation-mediated T cell actin dynamics. +% Science Signaling 9:rs3. doi: 10.1126/scisignal.aad4149. +% +% The updates include: +% 1. one point synapse annotation is allowed as valid input; +% 2. a method is implemented for synapse detection with only providing +% the first time point. +% 3. the method for aligmentment adjustment is implemented. +% +% The slowest step, which typically takes about 1 min per cell per frame, +% is to align each cell at each time to the standardized template. +% This demo uses 46 cells so it will take about 1 hour on a single core. +% +% Input +% ----- +% * image and annotation files for one or more proteins for the first +% time point (the default is to use images from the paper of LAT at time 0 +% - downloading the needed images requires about 4 GB of free disk space) +% +% Output +% ------ +% * a model for the average concentration in each voxel of a standardized +% cell shape (in demos/LAT_reltime_1.mat) +% * various intermediate results files (in /param and /tmp) + +% Author: Xiongtao Ruan +% +% Copyright (C) 2016-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +% set up intermediate result location +results_location = './models'; + +% set up synapse location +%synapse_location = {'../../../images/LAT/annotations/*.csv'}; +synapse_location = {'../../../images/LAT/annotations/coordinates 5C.C7 LAT 02 03 15.csv'}; + +options.model.tcell.ometiff = false; +% options.image_location = image_location; +options.model.tcell.synapse_location = synapse_location; + +options.results_location = results_location; +% the running choice for cellorganizer and one sensor of two-point annotation. +options.model.tcell.named_options_set = 'cellorganizer_one_sensor_1pt_synapse_infer_aligment_adjust'; + +% set up the mode of synapse to use, as a default, we use one-point, if +% needed you can use two-point by set up the option as true +options.model.tcell.use_two_point_synapses = ~true; + +% set up protein name +options.model.tcell.sensor = 'LAT'; + +% set up which time points need to analyze +options.model.tcell.timepoints_to_include = [-1, 0, 1, 4]; + +% set up synapse inference +options.model.tcell.infer_synapses = true; + +% set up alignment adjustment +options.model.tcell.adjust_one_point_alignment = true; + +% set up condition +% options.model.tcell.conditions_to_include = {'Full Stimulus'}; +options.model.tcell.model_type_to_include = {'standardized_voxels'}; +options.model.resolution = [0.049, 0.049, 0.2000]; + +% set up protein model type +options.protein.class = 'standardized_voxels'; +options.protein.type = 'standardized_map_half-ellipsoid'; + +% set up model name +options.model_prefix = 'LAT_'; + +% model.id (optional) Holds the id of the model. Default is empty. +options.model.id = uuidgen(); + +% set up model filename +options.model.filename = 'model.xml'; + +options.debug = true; +options.verbose = true; + +dimensionality = '3D'; +options.dimensionality = dimensionality; + +options.train.flag='protein'; + +answer = img2slml(dimensionality, {}, {}, {}, options); +end%demo3D48 diff --git a/demos/3D/demo3D49/demo3D49.m b/demos/3D/demo3D49/demo3D49.m new file mode 100644 index 0000000..a99ef88 --- /dev/null +++ b/demos/3D/demo3D49/demo3D49.m @@ -0,0 +1,113 @@ +function answer = demo3D49() +% demo3D49 +% +% This demo illustrates using CellOrganizer to train a protein distribution +% model following the approach described in +% +% K. T. Roybal, T. E. Buck, X. Ruan, B. H. Cho, D. J. Clark, R. Ambler, +% H. M. Tunbridge, J. Zhang, P. Verkade, C. Wuelfing, and R. F. Murphy (2016) +% Computational spatiotemporal analysis identifies WAVE2 and Cofilin as +% joint regulators of costimulation-mediated T cell actin dynamics. +% Science Signaling 9:rs3. doi: 10.1126/scisignal.aad4149. +% +% The slowest step, which typically takes about 1 min per cell per frame, +% is to align each cell at each time to the standardized template. +% This demo uses 46 cells so it will take about 1 hour on a single core. +% +% Input +% ----- +% * OMETIFF images with image and annotation files for one or more proteins for one or more +% time points (the default is to use images from the paper of LAT at time 0 +% - downloading the needed images requires about 4 GB of free disk space) +% +% Output +% ------ +% * a model for the average concentration in each voxel of a standardized +% cell shape (in demos/LAT_reltime_1.mat) +% * various intermediate results files (in /param and /tmp) + +% Author: Xiongtao Ruan, Xin Lu +% +% Copyright (C) 2016-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +% extract tif and annotation files from ometiff +directory = '../../../images/LAT/OME.TIFF/'; + +% set up intermediate result location +options.results_location = './models'; + +% the running choice for cellorganizer and one sensor of two-point annotation. +options.model.tcell.named_options_set = 'cellorganizer_one_sensor_2pt'; + +% set up the mode of synapse to use, as a default, we use one-point, if +% needed you can use two-point by set up the option as true +options.model.tcell.use_two_point_synapses = true; +options.model.tcell.ometiff = true; +% set up protein name +options.model.tcell.sensor = 'LAT'; + +% set up which time points need to analyze +options.model.tcell.timepoints_to_include = [0]; + +% set up condition +% options.model.tcell.conditions_to_include = {'Full Stimulus'}; +options.model.tcell.model_type_to_include = {'standardized_voxels'}; +options.model.resolution = [0.049, 0.049, 0.2000]; + +% set up protein model type +options.protein.class = 'standardized_voxels'; +options.protein.type = 'standardized_map_half-ellipsoid'; + +% set up model name +options.model_prefix = 'LAT_'; + +% model.id (optional) Holds the id of the model. Default is empty. + +try + [status, result] = system( 'uuidgen' ); + options.model.id = result(1:end-1); +catch + options.model.id = num2str(now); +end + +% set up model filename +options.model.filename = 'model.xml'; + +options.debug = true; +options.verbose = true; + +dimensionality = '3D'; +options.dimensionality = dimensionality; + +options.train.flag='protein'; + +answer = img2slml(dimensionality, {}, {}, directory, options); +end%demo3D49 diff --git a/demos/3D/demo3D50/demo3D50.m b/demos/3D/demo3D50/demo3D50.m new file mode 100644 index 0000000..386234c --- /dev/null +++ b/demos/3D/demo3D50/demo3D50.m @@ -0,0 +1,133 @@ +function answer = demo3D50(options) +% demo3D50 +% +% Train 3D generative SPHARM-RPDM cell shape model using the Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu +% +% 02/24/2019 xruan: specify options for alignment + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); +% get_murphylab_image_collections( true ); + cd(current_path); +end +disp( 'demo3D50' ); +options.verbose = true; +options.debug = false; +options.display = false; +options.model.name = 'demo3D50'; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'cell' ))); +options.cell.class = 'cell_membrane'; +options.cell.type = 'spharm_rpdm'; + +% criterion for rejecting spherical parameterization +options.hd_thresh = 10; +% postprocess of parameterization: alignment +options.model.spharm_rpdm.postprocess = ~false; +% alignment method: 'major_axis' or 'foe' +options.model.spharm_rpdm.alignment_method = 'major_axis'; +% plane of rotation: 'xy' 'yz', 'xz' or 'xyz' +options.model.spharm_rpdm.rotation_plane = 'xyz'; + +% degree of the descriptor +options.model.spharm_rpdm.maxDeg = 31; +% cellular components: either {'cell'}, {'nuc'}, or {'cell', 'nuc'} +options.model.spharm_rpdm.components = {'cell'}; + +% latent dimension for the model +options.model.spharm_rpdm.latent_dim = 15; +%increasing these numbers increases compute time but potentially +% improves model quality; the reported Hausdorff distances between the +% reconstructions and the original shapes can be used to evaluate this +options.NMfirsttry_maxiter = 300; +options.NMretry_maxiter = 100; +options.NMretry_maxiterbig = 300; +%decreasing these numbers decreases compute time but potentially reduces model quality +options.NMcost_tol = 1e-7; +options.NMlargr_tol = 1e-7; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% the following list of parameters are adapted to the LAMP3 image +% collection, modify these according to your needs +directory = '../../../images/HeLa/3D/processed/'; +dna = [ directory filesep 'LAM_cell[1-9]_ch0_t1.tif' ]; +cellm = [ directory filesep 'LAM_cell[1-9]_ch1_t1.tif' ]; +options.masks = [ directory filesep 'LAM_cell[1-9]_mask_t1.tif' ]; +%dna = [ directory filesep 'LAM_cell*_ch0_t1.tif' ]; +%cellm = [ directory filesep 'LAM_cell*_ch1_t1.tif' ]; +%options.masks = [ directory filesep 'LAM_cell*_mask_t1.tif' ]; + +options.model.resolution = [0.049, 0.049, 0.2000]; +options.downsampling = [5, 5, 1]; +options.model.filename = 'lamp2.xml'; +options.model.id = 'lamp2'; +options.model.name = 'lamp2'; +%set nuclei and cell model name +options.cell.model = 'LAMP2'; +%set the dimensionality of the model +dimensionality = '3D'; +%documentation +options.documentation.description = 'This model has been trained using demo3D50 from CellOrganizer'; +options.model.spharm_rpdm.segminnucfraction = 0.1; + +tic; answer = img2slml( dimensionality, cellm, cellm, [], options ); toc, + +options = []; +options.shape_evolution = 'none'; +options.labels = 'unique'; +options.subsize = 400; % smaller number means bigger objects +%options.viewangle = [0,90]; %down z axis +%options.viewangle = [90,0]; %side view +options.hd_threshold = 10.; % filter out objects with Hausdorff distance greater than this +slml2info({'lamp2.mat'},options); +cd report +web index.html +cd .. + +load('lamp2.mat'); +f = figure('visible','on'); +histogram(log10(model.cellShapeModel.hausdorff_distances(1,:)),25,'FaceColor','red') +xlabel('Log10 Hausdorff distance between original and SPHARM-RPDM model'); +ylabel('Frequency') +saveas( f, 'hausdorff_distance_histogram.png', 'png' ); + +end diff --git a/demos/3D/demo3D51/demo3D51.m b/demos/3D/demo3D51/demo3D51.m new file mode 100644 index 0000000..e3f83f7 --- /dev/null +++ b/demos/3D/demo3D51/demo3D51.m @@ -0,0 +1,58 @@ +function answer = demo3D51() +% demo3D51 +% +% Show shape evolution plot with a trained SPHARM-RPDM model with only cell shape +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file +% * a shape space plot + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end +disp( 'demo3D51' ); +disp( 'The estimated running time is 1 minutes. Please wait...' ); + +if exist( ['../demo3D50/lamp2.mat'] ) + answer = slml2info( {'../demo3D50/lamp2.mat'} ); +else + warning('The required file lamp2.mat does not exist in the model directory. Run demo3D50 first.'); + answer = false; +end diff --git a/demos/3D/demo3D52/demo3D52.m b/demos/3D/demo3D52/demo3D52.m new file mode 100644 index 0000000..62b0ed8 --- /dev/null +++ b/demos/3D/demo3D52/demo3D52.m @@ -0,0 +1,142 @@ +function answer = demo3D52(options) +% demo3D52 +% +% Train 3D generative SPHARM-RPDM nuclear and cell shape model using the +% Murphy Lab 3D HeLa dataset. +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu +% +% 02/24/2019 xruan: specify options for alignment +% 03/05/2021 R.F.Murphy add new options and add displays + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); +% get_murphylab_image_collections( true ); + cd(current_path); +end +disp( 'demo3D52' ); +options.verbose = true; +options.debug = false; +options.display = false; +options.model.name = 'demo3D52'; +options = ml_initparam( options, struct( ... + 'train', struct( 'flag', 'framework' ))); +options.nucleus.class = 'nuclear_membrane'; +options.nucleus.type = 'spharm_rpdm'; +options.cell.class = 'cell_membrane'; +options.cell.type = 'spharm_rpdm'; + +% criterion for rejecting spherical parameterization +options.hd_thresh = 10; +% postprocess of parameterization: alignment +options.model.spharm_rpdm.postprocess = ~false; +% alignment method: 'major_axis' or 'foe' +options.model.spharm_rpdm.alignment_method = 'major_axis'; +% plane of rotation: 'xy' 'yz', 'xz' or 'xyz' +options.model.spharm_rpdm.rotation_plane = 'xyz'; + +% degree of the descriptor +options.model.spharm_rpdm.maxDeg = 31; +% cellular components: either {'cell'}, {'nuc'}, or {'cell', 'nuc'} +options.model.spharm_rpdm.components = {'cell', 'nuc'}; + +% latent dimension for the model +options.model.spharm_rpdm.latent_dim = 15; +%increasing these numbers increases compute time but potentially +% improves model quality; the reported Hausdorff distances between the +% reconstructions and the original shapes can be used to evaluate this +options.NMfirsttry_maxiter = 300; +options.NMretry_maxiter = 100; +options.NMretry_maxiterbig = 300; +%decreasing these numbers decreases compute time but potentially reduces model quality +options.NMcost_tol = 1e-7; +options.NMlargr_tol = 1e-7; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% the following list of parameters are adapted to the LAMP3 image +% collection, modify these according to your needs +directory = '../../../images/HeLa/3D/processed/'; +%dna = [ directory filesep 'LAM_cell[1-9]_ch0_t1.tif' ]; +%cellm = [ directory filesep 'LAM_cell[1-9]_ch1_t1.tif' ]; +%options.masks = [ directory filesep 'LAM_cell[1-9]_mask_t1.tif' ]; +dna = [ directory filesep 'LAM_cell*_ch0_t1.tif' ]; +cellm = [ directory filesep 'LAM_cell*_ch1_t1.tif' ]; +options.masks = [ directory filesep 'LAM_cell*_mask_t1.tif' ]; + +options.model.resolution = [0.049, 0.049, 0.2000]; +options.downsampling = [5, 5, 1]; +options.model.filename = 'lamp2.xml'; +options.model.id = 'lamp2'; +options.model.name = 'lamp2'; +%set nuclei and cell model name +options.nucleus.name = 'LAMP2'; +options.cell.model = 'LAMP2'; +%set the dimensionality of the model +dimensionality = '3D'; +%documentation +options.documentation.description = 'This model has been trained using demo3D52 from CellOrganizer'; + +options.model.spharm_rpdm.segminnucfraction = 0.1; + +tic; answer = img2slml( dimensionality, dna, cellm, [], options ); toc, + +options = []; +options.shape_evolution = 'none'; +options.labels = 'unique'; +options.subsize = 400; % smaller number means bigger objects +%options.viewangle = [0,90]; %down z axis +%options.viewangle = [90,0]; %side view +options.hd_threshold = 10.; % filter out objects with Hausdorff distance greater than this +slml2info({'lamp2.mat'},options); +cd report +web index.html +cd .. + +load('lamp2.mat'); +f = figure('visible','on'); +histogram(log10(model.cellShapeModel.hausdorff_distances(1,:)),25,'FaceColor','red') +hold on +histogram(log10(model.cellShapeModel.hausdorff_distances(2,:)),25,'FaceColor','green') +xlabel('Log10 Hausdorff distance between original and SPHARM-RPDM model'); +ylabel('Frequency') +legend('cells','nuclei') +saveas( f, 'hausdorff_distance_histogram.png', 'png' ); + +end diff --git a/demos/3D/demo3D53/demo3D53.m b/demos/3D/demo3D53/demo3D53.m new file mode 100644 index 0000000..176c71f --- /dev/null +++ b/demos/3D/demo3D53/demo3D53.m @@ -0,0 +1,75 @@ +function answer = demo3D53() +% demo3D53 +% +% Reconstruct one 3D image with nuclear, cell shape for SPHARM-RPDM model +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * one TIFF file with three slices (nuclear, cell shape, and lysosomal +% channels) + +% Copyright (C) 2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end +disp( 'demo3D53' ); +disp( 'The estimated running time is 1 minute. Please wait.' ); +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%modify the next line to generate more images +options.numberOfSynthesizedImages = 1; +options.synthesis = 'framework'; +options.model.spharm_rpdm.synthesis_method = 'reconstruction'; +options.model.spharm_rpdm.imageSize = [205, 205, 18]; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.debug = false; +options.verbose = true; +options.display = false; + +filename = '../demo3D52/lamp2.mat'; +if ~exist( filename ) + warning( [ 'File ' filename ' not found.' ] ); + answer = false; + return +end + +answer = slml2img( {filename}, options ); +end diff --git a/demos/3D/demo3D54/demo3D54.m b/demos/3D/demo3D54/demo3D54.m new file mode 100644 index 0000000..c7f13c1 --- /dev/null +++ b/demos/3D/demo3D54/demo3D54.m @@ -0,0 +1,65 @@ +function answer = demo3D54() +% demo3D54 +% +% Show shape evolution plot with a trained SPHARM-RPDM model +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file +% * a shape space plot + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end +disp( 'demo3D54' ); +directory = '../demo3D52'; +if exist( [directory filesep 'lamp2.mat'] ) + load( [directory filesep 'lamp2.mat'] ); + show_SPHARM_RPDM_shape_evolution_figure(model); + saveas( gcf, 'show_shape_evolution.png', 'png' ); + if exist( [ pwd filesep 'show_shape_evolution.png' ] ) + answer = true; + else + answer = false; + end +else + disp('Please run demo3D52 first.'); + answer = false; +end +end diff --git a/demos/3D/demo3D55/demo3D55.m b/demos/3D/demo3D55/demo3D55.m new file mode 100644 index 0000000..52e81c1 --- /dev/null +++ b/demos/3D/demo3D55/demo3D55.m @@ -0,0 +1,60 @@ +function answer = demo3D55() +% demo3D55 +% +% Show shape space plot with a trained SPHARM-RPDM model +% +% Input +% ----- +% * a directory of raw or synthetic nucleus images +% * a directory of raw or synthetic cell shape images +% * the resolution of the images (all images should have the same +% resolution) +% +% Output +% ------ +% * a valid SLML model file +% * a shape space plot + +% Xiongtao Ruan (xruan@andrew.cmu.edu) +% +% Copyright (C) 2018 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end +disp( 'demo3D55' ); +disp( 'The estimated running time is 1 minutes. Please wait...' ); + +model_dir = '../demo3D52'; +if exist( [model_dir filesep 'lamp2.mat'] ) + answer = slml2info( {[model_dir filesep 'lamp2.mat']} ); +else + disp ('Run demo3D52 first' ); + answer = false; +end + diff --git a/demos/3D/demo3D56/demo3D56.m b/demos/3D/demo3D56/demo3D56.m new file mode 100644 index 0000000..486d4c1 --- /dev/null +++ b/demos/3D/demo3D56/demo3D56.m @@ -0,0 +1,121 @@ +function answer = demo3D56() +% demo3D56 +% +% This demo illustrates using CellOrganizer to train an updated version of +% protein distribution model following the approach described in +% +% K. T. Roybal, T. E. Buck, X. Ruan, B. H. Cho, D. J. Clark, R. Ambler, +% H. M. Tunbridge, J. Zhang, P. Verkade, C. Wülfing, and R. F. Murphy (2016) +% Computational spatiotemporal analysis identifies WAVE2 and Cofilin as +% joint regulators of costimulation-mediated T cell actin dynamics. +% Science Signaling 9:rs3. doi: 10.1126/scisignal.aad4149. +% +% The updates include: +% 1. one point synapse annotation is allowed as valid input; +% 2. a method is implemented for synapse detection with only providing +% the first time point. +% 3. the method for aligmentment adjustment is implemented. +% +% The slowest step, which typically takes about 1 min per cell per frame, +% is to align each cell at each time to the standardized template. +% This demo uses 46 cells so it will take about 1 hour on a single core. +% +% Input +% ----- +% * OMETIFF images with image and annotation files for one or more proteins for the first +% time point (the default is to use images from the paper of LAT at time 0 +% - downloading the needed images requires about 4 GB of free disk space) +% +% Output +% ------ +% * a model for the average concentration in each voxel of a standardized +% cell shape (in demos/LAT_reltime_1.mat) +% * various intermediate results files (in /param and /tmp) + +% Author: Xiongtao Ruan, Xin Lu +% +% Copyright (C) 2016-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + get_murphylab_image_collections( true ); + cd(current_path); +end + +% extract tif and annotation files from ometiff +directory = '../../../images/LAT/OME.TIFF/'; + +% set up intermediate result location +results_location = './models'; +options.results_location = results_location; + +options.model.tcell.ometiff = true; +% the running choice for cellorganizer and one sensor of two-point annotation. +options.model.tcell.named_options_set = 'cellorganizer_one_sensor_1pt_synapse_infer_aligment_adjust'; + +% set up the mode of synapse to use, as a default, we use one-point, if +% needed you can use two-point by set up the option as true +options.model.tcell.use_two_point_synapses = ~true; + +% set up protein name +options.model.tcell.sensor = 'LAT'; + +% set up which time points need to analyze +options.model.tcell.timepoints_to_include = [-1, 0, 4]; + +% set up synapse inference +options.model.tcell.infer_synapses = true; + +% set up alignment adjustment +options.model.tcell.adjust_one_point_alignment = true; + +% set up condition +% options.model.tcell.conditions_to_include = {'Full Stimulus'}; +options.model.tcell.model_type_to_include = {'standardized_voxels'}; +options.model.resolution = [0.049, 0.049, 0.2000]; + +% set up protein model type +options.protein.class = 'standardized_voxels'; +options.protein.type = 'standardized_map_half-ellipsoid'; + +% set up model name +options.model_prefix = 'LAT_'; + +% model.id (optional) +options.model.id = uuidgen(); + +% set up model filename +options.model.filename = 'model.xml'; + +options.debug = true; +options.verbose = true; + +dimensionality = '3D'; +options.dimensionality = dimensionality; + +options.train.flag='protein'; + +answer = img2slml(dimensionality, {}, {}, {directory}, options); +end diff --git a/demos/3D/demo3D57/demo3D57.m b/demos/3D/demo3D57/demo3D57.m new file mode 100644 index 0000000..daf02cb --- /dev/null +++ b/demos/3D/demo3D57/demo3D57.m @@ -0,0 +1,95 @@ +function answer = demo3D57() +% demo3D57 +% +% This demo illustrates using CellOrganizer to show protein enrichment plot +% for certain regions of the 3D T cell following the approach described in +% +% K. T. Roybal, T. E. Buck, X. Ruan, B. H. Cho, D. J. Clark, R. Ambler, +% H. M. Tunbridge, J. Zhang, P. Verkade, C. Wülfing, and R. F. Murphy (2016) +% Computational spatiotemporal analysis identifies WAVE2 and Cofilin as +% joint regulators of costimulation-mediated T cell actin dynamics. +% Science Signaling 9:rs3. doi: 10.1126/scisignal.aad4149. +% +%ShowTcellEnrichment +% Input +% ----- +% * a set of t cell models with different time points +% +% Output +% ------ +% * Plots of enrichment for different purposes. + +% Author: Xiongtao Ruan +% +% Copyright (C) 2016-2019 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end +disp( 'demo3D57' ); + + +filename = '../demo3D48/models'; +if ~exist( filename ) + warning( [ 'File ' filename ' not found. Run demo3D48 first.' ] ); + answer = false; + return +end + +options = struct(); +% Define the cylinder for the larger region (numerator) +% the radius of the ring +options.model.tcell.region_2_radius = [8, 8 / 3]; +% the height of the cylinder +options.model.tcell.region_2_thickness = [4, 4]; +% the top index of the cylinder starting from the top of the cell (1 means +% from the topmost of the cell) +options.model.tcell.region_2_start_ind = [1, 1]; + +% define the enrichment region as the ring +options.model.tcell.enrichment_region_type = 'ring'; + +% set the default parameter using top n% fluorescence as false +options.model.tcell.should_use_global_enrichment_region = false; + +% set the paramter for user defined enrichment region as true +options.model.tcell.should_use_user_defined_enrichment_region = true; + +% set the paramter for enrichment over certain region as true +options.model.tcell.enrichment_over_certain_region = true; + +% set the parameter for the type of the region in the denominator +options.model.tcell.enrichment_bottom_region_type = 'top_fluorescence'; + +% set the errorbar type as sem +options.model.tcell.error_bar_type = 'sem'; + +% set the result filename for the all the enrichment +options.model.tcell.save_result_filename = 'enrichment_result_ring_over_top90.csv'; + +disp('Show enrichment plots for T cell model'); +slml2info({'../demo3D48/models/LAT_reltime_-1.mat','../demo3D48/models/LAT_reltime_0.mat','../demo3D48/models/LAT_reltime_1.mat','../demo3D48/models/LAT_reltime_4.mat'},options) +end diff --git a/demos/3D/demo3D58/demo3D58.m b/demos/3D/demo3D58/demo3D58.m new file mode 100644 index 0000000..bd34466 --- /dev/null +++ b/demos/3D/demo3D58/demo3D58.m @@ -0,0 +1,95 @@ +function answer = demo3D58() +% demo3D58 +% +% Synthesize one 3D image with nuclear, cell shape and a vesicular channel using the ratio framework model and write the geometry to a valid VCML file. +% +% Input +% ----- +% * a valid CellOrganizer model file +% +% Output +% ------ +% * VCML file +% * three TIFF files (nuclear, cell shape, and lysosome channels) + +% Robert F. Murphy +% +% Copyright (C) 2012-2020 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +start_time = tic; +start_cputime = cputime; +disp( mfilename ); +disp( 'The estimated running time is about 2 minutes. Please wait.' ); + +disp( 'demo3D58' ); +options.seed = 12345; +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +options.targetDirectory = pwd; +options.prefix = 'img'; +options.compression = 'lzw'; +options.sampling.method = 'disc'; +options.debug = false; +options.verbose = true; +options.display = false; +options.output.OMETIFF = true; +options.output.tifimages = true; +options.numberOfGaussianObjects = 20; +options.temporary_results = [ pwd filesep 'temporary_results' ]; +options.rendAtStd = 2.0; +options.objstd = options.rendAtStd+0.3; +options.SBML.downsampling = [1/8, 1/8, 1]; +options.output.SBMLSpatial = true; +options.SBML.spatial_use_compression = false; +% Branch for this to be fully functional possibly not merged into dev yet but turn on anyway +options.output.VCML.writeVCML = true; +options.VCML.translations = {'cell', 'CP'; 'nucleus', 'NU'; 'lamp2_mat', 'EN'; 'CP_EC', 'PM'; 'CP_EN', 'EM'; 'CP_NU', 'NM'}; +options.VCML.downsampling = [1/4, 1/4, 1]; +options.output.meshes = true; +options.output.indexedimage = true; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK +list_of_models = {'../../../models/3D/lamp2.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( list_of_models, options ); + + +elapsed_time = toc(start_time); +elapsed_cputime = cputime - start_cputime; +fprintf('\n%s took %.3f s (%.3f s CPU time)\n\n', mfilename, elapsed_time, elapsed_cputime); diff --git a/demos/3D/demo3D59/demo3D59.m b/demos/3D/demo3D59/demo3D59.m new file mode 100644 index 0000000..1a5021e --- /dev/null +++ b/demos/3D/demo3D59/demo3D59.m @@ -0,0 +1,98 @@ +function answer = demo3D59( options ) +% demo3D59 +% +% Synthesize one 3D image with nuclear, cell shape and a vesicular channel. +% This demo exports portions of the synthetic image as an SBML Spatial instance. +% +% Input +% ----- +% * a valid CellOrganizer model +% +% Output +% ------ +% * SBML instance +% * single channel TIF files + +% Author: Ivan E. Cao-Berg, Taraz Buck +% +% Copyright (C) 2016-2019 Murphy Lab +% Lane Center for Computational Biology +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +% The framework (cell and nucleus shapes) will be synthesized using framework_model +framework_model = '../../../models/3D/spharm/lamp2.mat'; +vesicle_models = '../../../models/3D/tfr.mat'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( mfilename ); +disp( 'The estimated running time is about 6 minutes. Please wait.' ); + +% Combine SPHARM framework with vesicle models +combined_models = 'combined_model.mat'; +slml2slml({framework_model, vesicle_models}, struct('output_filename', combined_models, 'selection', [1,1,0;0,0,1])); + +options.seed = 639848; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.synthesis = 'all'; +options.model.spharm_rpdm.synthesis_method = 'random_sampling'; +options.model.spharm_rpdm.imageSize = [205, 205, 18]; +options.numberOfSynthesizedImages = 1; +options.numberOfGaussianObjects = 100; +options.rendAtStd = 1; +options.overlapthresh = 1; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.tifimages = true; +options.output.OMETIFF = true; +options.output.indexedimage = true; +options.output.SBMLSpatial = true; +% options.SBML.downsampling = [1/4, 1/4, 1]; +options.SBML.spatial_use_compression = true; +options.SBML.spatial_use_analytic_meshes = ~false; +options.SBML.spatial_image = false; +options.SBML.spatial_vcell_compatible = false; +options.oobbuffer = 0.1; + +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +answer = slml2img( {combined_models}, options ); +end%demo3D59 diff --git a/demos/3D/demo3D60/demo3D60.m b/demos/3D/demo3D60/demo3D60.m new file mode 100644 index 0000000..4832984 --- /dev/null +++ b/demos/3D/demo3D60/demo3D60.m @@ -0,0 +1,108 @@ +function answer = demo3D60( options ) +% demo3D60 +% +% Synthesize one 3D image with nuclear, cell shape and a vesicular channel using the SPHARM framework model. +% This demo exports the synthetic image as Virtual Cell VCML. +% +% Input +% ----- +% * a valid CellOrganizer model +% +% Output +% ------ +% * VCML file +% * single channel TIF files + +% Author: Ivan E. Cao-Berg, Taraz Buck +% +% Copyright (C) 2016-2020 Murphy Lab +% Lane Center for Computational Biology +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +% The framework (cell and nucleus shapes) will be synthesized using framework_model +framework_model = '../../../models/3D/spharm/lamp2.mat'; +vesicle_models = '../../../models/3D/tfr.mat'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +start_time = tic; +start_cputime = cputime; +disp( mfilename ); +disp( 'The estimated running time is about 1 minute. Please wait.' ); + +% Combine SPHARM framework with vesicle models +combined_models = 'combined_model.mat'; +slml2slml({framework_model, vesicle_models}, ... + struct('output_filename', combined_models, ... + 'selection', [1,1,0;0,0,1])); + +options.seed = 639848; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.synthesis = 'all'; +options.model.spharm_rpdm.synthesis_method = 'random_sampling'; +options.model.spharm_rpdm.imageSize = [512, 512, 36]; +options.model.spharm_rpdm.synthesis_resolution = [0.10 0.10 0.1]; +options.numberOfSynthesizedImages = 1; +options.numberOfGaussianObjects = 5; +options.rendAtStd = 2.0; +options.objstd = options.rendAtStd+0.3; +options.overlapsubsize = 1; +options.overlapthresh = 0; +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.tifimages = true; +options.output.indexedimage = true; + +% VCML Options +options.output.VCML.writeVCML = true; +options.VCML.downsampling = 1; +options.VCML.translations = {'cell', 'CP'; 'nucleus', 'NU'; ... + 'lamp2_mat_tfr_mat', 'EN'; ... + 'CP_EC', 'PM'; ... + 'CP_EN', 'EM'; ... + 'CP_NU', 'NM'}; + +options.overlapsubsize = options.VCML.downsampling; +options.overlapthresh = 0; + +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +% Synthesize Image and VCML file +answer = slml2img( { combined_models }, options ); diff --git a/demos/3D/demo3D60/journal.pcbi.1004611.s003_volareaadjust.net b/demos/3D/demo3D60/journal.pcbi.1004611.s003_volareaadjust.net new file mode 100644 index 0000000..53a2ff1 --- /dev/null +++ b/demos/3D/demo3D60/journal.pcbi.1004611.s003_volareaadjust.net @@ -0,0 +1,612 @@ +# Created by BioNetGen 2.4.0 +begin parameters + nEndo 5 + vol_EC 1215.146638 + vol_CP 411.435494 + vol_NU 378.268712 + vol_EN 6.790818 + sa_PM 245.221928 + sa_NM 94.540854 + sa_EM 7.529536 + eff_width ((((37.5+39.5)+35.6)+42.5)/4)*1e-4 + vol_PM sa_PM*eff_width + vol_NM sa_NM*eff_width + L0 1000 + R0 200 + TF0 200 + DNA0 2 + Im0 40 + NP0 4 + kp_LR 0.1 + km_LR 1.0 + kp_LL 0.1 + km_LL 1.0 + k_R_endo 1.0 + k_recycle 0.1 + k_R_transphos 1.0 + k_R_dephos 0.1 + kp_R_TF 0.1 + km_R_TF 0.1 + kp_R_TFp 0.1 + km_R_TFp 10.0 + k_TF_transphos 1.0 + k_TF_dephos 1.0 + kp_TF_TF 0.1 + km_TF_TF 1.0 + kp_TF_p1 0.1 + km_TF_p1 1.0 + k_transcribe 1.0 + k_translate 1.0 + k_mRNA_to_CP 1.0 + k_mRNA_deg 1.0 + k_P_deg 0.1 + k_Im_bind_CP 0.1 + k_Im_unbind_CP 0.1 + k_Im_bind_NU 0.1 + k_Im_unbind_NU 10.0 + k_Im_enters_NP 0.1 + k_Im_exits_NP 1.0 + k_Im_cross_NP 1.0 + kp_P1_p2 0.1 + km_P1_p2 1.0 +end parameters +begin compartments + EC 3 vol_EC + PM 2 sa_PM*eff_width EC + CP 3 vol_CP PM + NM 2 sa_NM*eff_width CP + NU 3 vol_NU NM + EM 2 sa_EM*eff_width CP + EN 3 vol_EN EM +end compartments +begin molecule types + DNA(p1,p2) + Im(fg,cargo) + L(r,d) + NP(fg) + P1(im,dna) + P2() + R(l,tf~Y~pY) + Sink() + TF(r,d~Y~pY,dna,im) + mRNA1() + mRNA2() +end molecule types +begin observables + Molecules Tot_L L() + Molecules Tot_R R() + Molecules Tot_TF TF() + Molecules Tot_DNA DNA() + Molecules Tot_mRNA1 mRNA1() + Molecules Tot_mRNA2 mRNA2() + Molecules Tot_P1 P1() + Molecules Tot_P2 P2() + Molecules Tot_NP NP() + Molecules Tot_Im Im() + Species L_Dimers_EC @EC::{MatchOnce}L().L() + Species L_Dimers_PM @PM::{MatchOnce}L().L() + Species L_Dimers_EN @EN::{MatchOnce}L().L() + Species L_Dimers_EM @EM::{MatchOnce}L().L() + Molecules L_Bound_PM @PM::L() + Molecules L_Bound_EM @EM::L() + Species R_Dimers_PM @PM::{MatchOnce}R().R() + Species R_Dimers_EM @EM::{MatchOnce}R().R() + Molecules Catalytic_R R(tf~pY!?) + Molecules Catalytic_TF R(tf~pY!1).TF(r!1) + Molecules Phos_TF TF(d~pY!?) + Species TF_Dimer_CP {MatchOnce}TF(d~pY!1)@CP.TF(d~pY!1)@CP + Species TF_Dimer_NU {MatchOnce}TF(d~pY!1)@NU.TF(d~pY!1)@NU + Species Bound_prom1 {MatchOnce}DNA(p1!+) + Species Bound_prom2 {MatchOnce}DNA(p2!+) + Species P1_NU {MatchOnce}P1()@NU + Species P1_CP {MatchOnce}P1()@CP + Species Im_NU {MatchOnce}Im()@NU + Species Im_CP {MatchOnce}Im()@CP + Species Im_Cargo_NP {MatchOnce}Im(fg!+,cargo!+) + Species P1_NU_free {MatchOnce}P1(im,dna)@NU + Species P1_NU_dna {MatchOnce}P1(im,dna!+)@NU + Species CountSink {MatchOnce}Sink()@CP +end observables +begin species + @EC::L(d,r) L0 + @PM::R(l,tf~Y) R0 + @CP::TF(d~Y,dna,im,r) TF0 + @NU::DNA(p1,p2) DNA0 + @CP::Im(cargo,fg) Im0 + @NM::NP(fg) NP0 + @CP::$Sink() 0 + @PM::L(d,r!1)@EC.R(l!1,tf~Y) 0 + @EC::L(d!1,r).L(d!1,r) 0 + @NM::Im(cargo,fg!1)@CP.NP(fg!1) 0 + @PM::L(d!1,r!2)@EC.L(d!1,r)@EC.R(l!2,tf~Y) 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!2,tf~Y).R(l!3,tf~Y) 0 + @NM::Im(cargo,fg!1)@NU.NP(fg!1) 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!2,tf~Y).R(l!3,tf~Y) 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!2,tf~Y).R(l!3,tf~pY) 0 + @NU::Im(cargo,fg) 0 + @EM::L(d!1,r!2)@EN.L(d!1,r)@EN.R(l!2,tf~Y) 0 + @EM::R(l,tf~Y) 0 + @PM::L(d!1,r!2)@EC.L(d!1,r)@EC.R(l!2,tf~pY) 0 + @PM::R(l,tf~pY) 0 + @EM::L(d,r!1)@EN.R(l!1,tf~Y) 0 + @PM::L(d,r!1)@EC.R(l!1,tf~pY) 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!2,tf~Y).R(l!3,tf~pY) 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!2,tf~pY).R(l!3,tf~pY) 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!2,tf~Y).R(l!3,tf~pY!4).TF(d~Y,dna,im,r!4)@CP 0 + @EN::L(d!1,r).L(d!1,r) 0 + @EN::L(d,r) 0 + @EM::L(d!1,r!2)@EN.L(d!1,r)@EN.R(l!2,tf~pY) 0 + @EM::R(l,tf~pY) 0 + @PM::L(d!1,r!2)@EC.L(d!1,r)@EC.R(l!2,tf~pY!3).TF(d~Y,dna,im,r!3)@CP 0 + @PM::R(l,tf~pY!1).TF(d~Y,dna,im,r!1)@CP 0 + @EM::L(d,r!1)@EN.R(l!1,tf~pY) 0 + @PM::L(d,r!1)@EC.R(l!1,tf~pY!2).TF(d~Y,dna,im,r!2)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!2,tf~pY).R(l!3,tf~pY) 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!2,tf~Y).R(l!3,tf~pY!4).TF(d~Y,dna,im,r!4)@CP 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!3,tf~pY!4).R(l!2,tf~pY).TF(d~Y,dna,im,r!4)@CP 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!2,tf~pY!4).R(l!3,tf~pY!5).TF(d~Y,dna,im,r!4)@CP.TF(d~Y,dna,im,r!5)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r)@EN.R(l!2,tf~pY!3).TF(d~Y,dna,im,r!3)@CP 0 + @EM::R(l,tf~pY!1).TF(d~Y,dna,im,r!1)@CP 0 + @EM::L(d,r!1)@EN.R(l!1,tf~pY!2).TF(d~Y,dna,im,r!2)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!3,tf~pY!4).R(l!2,tf~pY).TF(d~Y,dna,im,r!4)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!2,tf~pY!4).R(l!3,tf~pY!5).TF(d~Y,dna,im,r!4)@CP.TF(d~Y,dna,im,r!5)@CP 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!2,tf~pY!4).R(l!3,tf~pY!5).TF(d~Y,dna,im,r!4)@CP.TF(d~pY,dna,im,r!5)@CP 0 + @PM::L(d!1,r!2)@EC.L(d!1,r)@EC.R(l!2,tf~pY!3).TF(d~pY,dna,im,r!3)@CP 0 + @PM::R(l,tf~pY!1).TF(d~pY,dna,im,r!1)@CP 0 + @PM::L(d,r!1)@EC.R(l!1,tf~pY!2).TF(d~pY,dna,im,r!2)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!2,tf~pY!4).R(l!3,tf~pY!5).TF(d~Y,dna,im,r!4)@CP.TF(d~pY,dna,im,r!5)@CP 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!3,tf~pY!4).R(l!2,tf~pY).TF(d~pY,dna,im,r!4)@CP 0 + @CP::TF(d~pY,dna,im,r) 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!2,tf~pY!4).R(l!3,tf~pY!5).TF(d~pY,dna,im,r!4)@CP.TF(d~pY,dna,im,r!5)@CP 0 + @PM::L(d!1,r!2)@EC.L(d!1,r!3)@EC.R(l!2,tf~Y).R(l!3,tf~pY!4).TF(d~pY,dna,im,r!4)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r)@EN.R(l!2,tf~pY!3).TF(d~pY,dna,im,r!3)@CP 0 + @EM::R(l,tf~pY!1).TF(d~pY,dna,im,r!1)@CP 0 + @EM::L(d,r!1)@EN.R(l!1,tf~pY!2).TF(d~pY,dna,im,r!2)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!3,tf~pY!4).R(l!2,tf~pY).TF(d~pY,dna,im,r!4)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!2,tf~pY!4).R(l!3,tf~pY!5).TF(d~pY,dna,im,r!4)@CP.TF(d~pY,dna,im,r!5)@CP 0 + @EM::L(d!1,r!2)@EN.L(d!1,r!3)@EN.R(l!2,tf~Y).R(l!3,tf~pY!4).TF(d~pY,dna,im,r!4)@CP 0 + @CP::TF(d~pY!1,dna,im,r).TF(d~pY!1,dna,im,r) 0 + @CP::Im(cargo!1!2,fg).TF(d~pY!3,dna,im!1,r).TF(d~pY!3,dna,im!2,r) 0 + @NM::Im(cargo!1!2,fg!3)@CP.NP(fg!3).TF(d~pY!4,dna,im!1,r)@CP.TF(d~pY!4,dna,im!2,r)@CP 0 + @NM::Im(cargo!1!2,fg!3)@NU.NP(fg!3).TF(d~pY!4,dna,im!1,r)@NU.TF(d~pY!4,dna,im!2,r)@NU 0 + @NU::TF(d~pY!1,dna,im,r).TF(d~pY!1,dna,im,r) 0 + @NU::Im(cargo!1!2,fg).TF(d~pY!3,dna,im!1,r).TF(d~pY!3,dna,im!2,r) 0 + @NU::TF(d~pY,dna,im,r) 0 + @NU::DNA(p1!1!2,p2).TF(d~pY!3,dna!1,im,r).TF(d~pY!3,dna!2,im,r) 0 + @NU::mRNA1() 0 + @CP::mRNA1() 0 + @CP::P1(dna,im) 0 + @CP::Im(cargo!1,fg).P1(dna,im!1) 0 + @NM::Im(cargo!1,fg!2)@CP.NP(fg!2).P1(dna,im!1)@CP 0 + @NM::Im(cargo!1,fg!2)@NU.NP(fg!2).P1(dna,im!1)@NU 0 + @NU::P1(dna,im) 0 + @NU::Im(cargo!1,fg).P1(dna,im!1) 0 + @NU::DNA(p1,p2!1).P1(dna!1,im) 0 + @NU::DNA(p1!1!2,p2!3).P1(dna!3,im).TF(d~pY!4,dna!1,im,r).TF(d~pY!4,dna!2,im,r) 0 + @NU::mRNA2() 0 + @CP::mRNA2() 0 + @CP::P2() 0 +end species +begin reaction rules + Rule1: L(r) + R(l) <-> L(r!1).R(l!1) kp_LR, km_LR + Rule2: L(d) + L(d) <-> L(d!1).L(d!1) kp_LL, km_LL + Rule3: @PM::R().R() -> @EM::R().R() k_R_endo + Rule4: @EM::R() -> @PM::R() k_recycle + Rule5: @EN::L() -> @EC::L() k_recycle + Rule6: R().R(tf~Y) -> R().R(tf~pY) k_R_transphos + Rule7: R(tf~pY) -> R(tf~Y) k_R_dephos + Rule8: R(tf~pY) + TF(d~Y,r) <-> R(tf~pY!1).TF(d~Y,r!1) kp_R_TF, km_R_TF + Rule9: R(tf~pY) + TF(d~pY,r) <-> R(tf~pY!1).TF(d~pY,r!1) kp_R_TFp, km_R_TFp + Rule10: TF().R().R().TF(d~Y) -> TF().R().R().TF(d~pY) k_TF_transphos + Rule11: TF(d~pY)@CP -> TF(d~Y)@CP k_TF_dephos + Rule12: TF(r,d~pY,dna) + TF(r,d~pY,dna) <-> TF(r,d~pY!1,dna).TF(r,d~pY!1,dna) kp_TF_TF, km_TF_TF + Rule13: TF(dna,im).TF(dna,im) + DNA(p1) <-> TF(dna!1,im).TF(dna!2,im).DNA(p1!1!2) kp_TF_p1, km_TF_p1 + Rule14: DNA(p1!+) -> DNA(p1!+) + mRNA1()@NU k_transcribe + Rule15: DNA(p2!+) -> DNA(p2!+) + mRNA2()@NU k_transcribe + Rule16: mRNA1()@NU -> mRNA1()@CP k_mRNA_to_CP + Rule17: mRNA2()@NU -> mRNA2()@CP k_mRNA_to_CP + Rule18: mRNA1()@CP -> mRNA1()@CP + P1(im,dna)@CP k_translate + Rule19: mRNA2()@CP -> mRNA2()@CP + P2()@CP k_translate + Rule20: mRNA1() -> Sink()@CP k_mRNA_deg DeleteMolecules + Rule21: mRNA2() -> Sink()@CP k_mRNA_deg DeleteMolecules + Rule22: P1() -> Sink()@CP k_P_deg DeleteMolecules + Rule23: P2() -> Sink()@CP k_P_deg DeleteMolecules + Rule24: TF(im,dna,r).TF(im,dna,r) + Im(cargo)@CP <-> TF(im!1,dna,r).TF(im!2,dna,r).Im(cargo!1!2)@CP k_Im_bind_CP, k_Im_unbind_CP + Rule25: TF(im,dna,r).TF(im,dna,r) + Im(cargo)@NU <-> TF(im!1,dna,r).TF(im!2,dna,r).Im(cargo!1!2)@NU k_Im_bind_NU, k_Im_unbind_NU + Rule26: P1(im,dna) + Im(cargo)@CP <-> P1(im!1,dna).Im(cargo!1)@CP k_Im_bind_CP, k_Im_unbind_CP + Rule27: P1(im,dna) + Im(cargo)@NU <-> P1(im!1,dna).Im(cargo!1)@NU k_Im_bind_NU, k_Im_unbind_NU + Rule28: Im(fg) + NP(fg) <-> Im(fg!1).NP(fg!1) k_Im_enters_NP, k_Im_exits_NP + Rule29: Im(fg!1)@CP.NP(fg!1) <-> Im(fg!1)@NU.NP(fg!1) k_Im_cross_NP, k_Im_cross_NP MoveConnected + Rule30: P1(im,dna) + DNA(p2) <-> P1(im,dna!1).DNA(p2!1) kp_P1_p2, km_P1_p2 +end reaction rules +begin reactions + 1 1,2 8 0.00082294595*kp_LR #Rule1 unit_conversion=1/vol_EC + 2 1,1 9 0.00041147297*kp_LL #Rule2 unit_conversion=1/vol_EC + 3 5,6 10 0.0024305147*k_Im_enters_NP #Rule28 unit_conversion=1/vol_CP + 4 2,9 11 0.0016458919*kp_LR #Rule1 unit_conversion=1/vol_EC + 5 8 1,2 km_LR #_reverse_Rule1 + 6 1,8 11 0.00082294595*kp_LL #Rule2 unit_conversion=1/vol_EC + 7 8,8 12 0.52584639*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 8 9 1,1 km_LL #_reverse_Rule2 + 9 10 5,6 k_Im_exits_NP #_reverse_Rule28 + 10 10 13 k_Im_cross_NP #Rule29 + 11 2,11 12 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 12 11 2,9 km_LR #_reverse_Rule1 + 13 12 2,11 2*km_LR #_reverse_Rule1 + 14 11 1,8 km_LL #_reverse_Rule2 + 15 12 8,8 km_LL #_reverse_Rule2 + 16 12 14 k_R_endo #Rule3 + 17 12 15 2*k_R_transphos #Rule6 + 18 13 6,16 k_Im_exits_NP #_reverse_Rule28 + 19 13 10 k_Im_cross_NP #_reverse_Rule29 + 20 14 17,18 2*km_LR #_reverse_Rule1 + 21 15 2,19 km_LR #_reverse_Rule1 + 22 15 11,20 km_LR #_reverse_Rule1 + 23 14 21,21 km_LL #_reverse_Rule2 + 24 15 8,22 km_LL #_reverse_Rule2 + 25 15 23 k_R_endo #Rule3 + 26 14 12 k_recycle #Rule4 + 27 14 23 2*k_R_transphos #Rule6 + 28 15 24 k_R_transphos #Rule6 + 29 15 12 k_R_dephos #Rule7 + 30 3,15 25 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 31 6,16 13 0.0026436234*k_Im_enters_NP #Rule28 unit_conversion=1/vol_NU + 32 1,20 22 0.00082294595*kp_LR #Rule1 unit_conversion=1/vol_EC + 33 9,20 19 0.0016458919*kp_LR #Rule1 unit_conversion=1/vol_EC + 34 11,20 15 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 35 17,18 14 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 36 2,19 15 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 37 19,20 24 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 38 17 18,26 km_LR #_reverse_Rule1 + 39 19 9,20 km_LR #_reverse_Rule1 + 40 21 18,27 km_LR #_reverse_Rule1 + 41 22 1,20 km_LR #_reverse_Rule1 + 42 23 18,28 km_LR #_reverse_Rule1 + 43 23 17,29 km_LR #_reverse_Rule1 + 44 24 19,20 2*km_LR #_reverse_Rule1 + 45 25 2,30 km_LR #_reverse_Rule1 + 46 25 11,31 km_LR #_reverse_Rule1 + 47 1,22 19 0.00082294595*kp_LL #Rule2 unit_conversion=1/vol_EC + 48 8,22 15 1.0516928*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 49 21,21 14 17.125765*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 50 22,22 24 0.52584639*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 51 17 21,27 km_LL #_reverse_Rule2 + 52 19 1,22 km_LL #_reverse_Rule2 + 53 23 21,32 km_LL #_reverse_Rule2 + 54 24 22,22 km_LL #_reverse_Rule2 + 55 25 8,33 km_LL #_reverse_Rule2 + 56 24 34 k_R_endo #Rule3 + 57 25 35 k_R_endo #Rule3 + 58 17 11 k_recycle #Rule4 + 59 18 2 k_recycle #Rule4 + 60 21 8 k_recycle #Rule4 + 61 23 15 k_recycle #Rule4 + 62 23 34 k_R_transphos #Rule6 + 63 25 36 k_R_transphos #Rule6 + 64 19 11 k_R_dephos #Rule7 + 65 20 2 k_R_dephos #Rule7 + 66 22 8 k_R_dephos #Rule7 + 67 23 14 k_R_dephos #Rule7 + 68 24 15 2*k_R_dephos #Rule7 + 69 3,19 30 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 70 3,20 31 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 71 3,22 33 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 72 3,23 35 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 73 3,24 36 0.0048610293*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 74 25 3,15 km_R_TF #_reverse_Rule8 + 75 1,31 33 0.00082294595*kp_LR #Rule1 unit_conversion=1/vol_EC + 76 9,31 30 0.0016458919*kp_LR #Rule1 unit_conversion=1/vol_EC + 77 11,31 25 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 78 17,29 23 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 79 19,31 36 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 80 18,26 17 0.29451533*kp_LR #Rule1 unit_conversion=1/vol_EN + 81 26,29 28 0.29451533*kp_LR #Rule1 unit_conversion=1/vol_EN + 82 18,27 21 0.14725766*kp_LR #Rule1 unit_conversion=1/vol_EN + 83 27,29 32 0.14725766*kp_LR #Rule1 unit_conversion=1/vol_EN + 84 18,28 23 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 85 28,29 34 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 86 2,30 25 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 87 20,30 36 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 88 30,31 37 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 89 28 26,29 km_LR #_reverse_Rule1 + 90 30 9,31 km_LR #_reverse_Rule1 + 91 32 27,29 km_LR #_reverse_Rule1 + 92 33 1,31 km_LR #_reverse_Rule1 + 93 34 28,29 2*km_LR #_reverse_Rule1 + 94 35 18,38 km_LR #_reverse_Rule1 + 95 35 17,39 km_LR #_reverse_Rule1 + 96 36 20,30 km_LR #_reverse_Rule1 + 97 36 19,31 km_LR #_reverse_Rule1 + 98 1,33 30 0.00082294595*kp_LL #Rule2 unit_conversion=1/vol_EC + 99 8,33 25 1.0516928*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 100 21,27 17 0.14725766*kp_LL #Rule2 unit_conversion=1/vol_EN + 101 21,32 23 34.25153*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 102 22,33 36 1.0516928*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 103 27,27 26 0.073628832*kp_LL #Rule2 unit_conversion=1/vol_EN + 104 27,32 28 0.14725766*kp_LL #Rule2 unit_conversion=1/vol_EN + 105 32,32 34 17.125765*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 106 33,33 37 0.52584639*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 107 26 27,27 km_LL #_reverse_Rule2 + 108 28 27,32 km_LL #_reverse_Rule2 + 109 30 1,33 km_LL #_reverse_Rule2 + 110 34 32,32 km_LL #_reverse_Rule2 + 111 35 21,40 km_LL #_reverse_Rule2 + 112 36 22,33 km_LL #_reverse_Rule2 + 113 36 41 k_R_endo #Rule3 + 114 28 19 k_recycle #Rule4 + 115 29 20 k_recycle #Rule4 + 116 32 22 k_recycle #Rule4 + 117 34 24 k_recycle #Rule4 + 118 35 25 k_recycle #Rule4 + 119 26 9 k_recycle #Rule5 + 120 27 1 k_recycle #Rule5 + 121 35 41 k_R_transphos #Rule6 + 122 28 17 k_R_dephos #Rule7 + 123 29 18 k_R_dephos #Rule7 + 124 32 21 k_R_dephos #Rule7 + 125 34 23 2*k_R_dephos #Rule7 + 126 36 25 k_R_dephos #Rule7 + 127 3,28 38 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 128 3,29 39 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 129 3,32 40 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 130 3,34 41 0.0048610293*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 131 3,36 37 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 132 30 3,19 km_R_TF #_reverse_Rule8 + 133 31 3,20 km_R_TF #_reverse_Rule8 + 134 33 3,22 km_R_TF #_reverse_Rule8 + 135 35 3,23 km_R_TF #_reverse_Rule8 + 136 36 3,24 km_R_TF #_reverse_Rule8 + 137 17,39 35 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 138 26,39 38 0.29451533*kp_LR #Rule1 unit_conversion=1/vol_EN + 139 27,39 40 0.14725766*kp_LR #Rule1 unit_conversion=1/vol_EN + 140 28,39 41 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 141 18,38 35 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 142 29,38 41 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 143 38,39 42 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 144 37 30,31 2*km_LR #_reverse_Rule1 + 145 38 26,39 km_LR #_reverse_Rule1 + 146 40 27,39 km_LR #_reverse_Rule1 + 147 41 29,38 km_LR #_reverse_Rule1 + 148 41 28,39 km_LR #_reverse_Rule1 + 149 21,40 35 34.25153*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 150 27,40 38 0.14725766*kp_LL #Rule2 unit_conversion=1/vol_EN + 151 32,40 41 34.25153*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 152 40,40 42 17.125765*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 153 37 33,33 km_LL #_reverse_Rule2 + 154 38 27,40 km_LL #_reverse_Rule2 + 155 41 32,40 km_LL #_reverse_Rule2 + 156 37 42 k_R_endo #Rule3 + 157 38 30 k_recycle #Rule4 + 158 39 31 k_recycle #Rule4 + 159 40 33 k_recycle #Rule4 + 160 41 36 k_recycle #Rule4 + 161 41 35 k_R_dephos #Rule7 + 162 3,41 42 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 163 37 3,36 2*km_R_TF #_reverse_Rule8 + 164 38 3,28 km_R_TF #_reverse_Rule8 + 165 39 3,29 km_R_TF #_reverse_Rule8 + 166 40 3,32 km_R_TF #_reverse_Rule8 + 167 41 3,34 km_R_TF #_reverse_Rule8 + 168 37 43 2*k_TF_transphos #Rule10 + 169 42 38,39 2*km_LR #_reverse_Rule1 + 170 43 31,44 km_LR #_reverse_Rule1 + 171 43 30,45 km_LR #_reverse_Rule1 + 172 42 40,40 km_LL #_reverse_Rule2 + 173 43 33,46 km_LL #_reverse_Rule2 + 174 43 47 k_R_endo #Rule3 + 175 42 37 k_recycle #Rule4 + 176 42 3,41 2*km_R_TF #_reverse_Rule8 + 177 43 3,48 km_R_TF #_reverse_Rule8 + 178 43 36,49 km_R_TFp #_reverse_Rule9 + 179 42 47 2*k_TF_transphos #Rule10 + 180 43 50 k_TF_transphos #Rule10 + 181 43 37 k_TF_dephos #Rule11 + 182 1,45 46 0.00082294595*kp_LR #Rule1 unit_conversion=1/vol_EC + 183 9,45 44 0.0016458919*kp_LR #Rule1 unit_conversion=1/vol_EC + 184 11,45 51 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 185 19,45 48 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 186 30,45 43 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 187 2,44 51 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 188 20,44 48 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 189 31,44 43 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 190 44,45 50 1.0516928*kp_LR #Rule1 unit_conversion=1/(sa_PM*eff_width) + 191 44 9,45 km_LR #_reverse_Rule1 + 192 46 1,45 km_LR #_reverse_Rule1 + 193 47 39,52 km_LR #_reverse_Rule1 + 194 47 38,53 km_LR #_reverse_Rule1 + 195 48 20,44 km_LR #_reverse_Rule1 + 196 48 19,45 km_LR #_reverse_Rule1 + 197 50 44,45 2*km_LR #_reverse_Rule1 + 198 1,46 44 0.00082294595*kp_LL #Rule2 unit_conversion=1/vol_EC + 199 8,46 51 1.0516928*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 200 22,46 48 1.0516928*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 201 33,46 43 1.0516928*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 202 46,46 50 0.52584639*kp_LL #Rule2 unit_conversion=1/(sa_PM*eff_width) + 203 44 1,46 km_LL #_reverse_Rule2 + 204 47 40,54 km_LL #_reverse_Rule2 + 205 48 22,46 km_LL #_reverse_Rule2 + 206 50 46,46 km_LL #_reverse_Rule2 + 207 48 55 k_R_endo #Rule3 + 208 50 56 k_R_endo #Rule3 + 209 47 43 k_recycle #Rule4 + 210 48 51 k_R_dephos #Rule7 + 211 3,48 43 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 212 47 3,55 km_R_TF #_reverse_Rule8 + 213 15,49 51 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 214 19,49 44 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 215 20,49 45 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 216 22,49 46 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 217 23,49 57 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 218 24,49 48 0.0048610293*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 219 28,49 52 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 220 29,49 53 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 221 32,49 54 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 222 34,49 55 0.0048610293*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 223 36,49 43 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 224 41,49 47 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 225 48,49 50 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 226 44 19,49 km_R_TFp #_reverse_Rule9 + 227 45 20,49 km_R_TFp #_reverse_Rule9 + 228 46 22,49 km_R_TFp #_reverse_Rule9 + 229 47 41,49 km_R_TFp #_reverse_Rule9 + 230 48 24,49 km_R_TFp #_reverse_Rule9 + 231 50 48,49 2*km_R_TFp #_reverse_Rule9 + 232 47 56 k_TF_transphos #Rule10 + 233 44 30 k_TF_dephos #Rule11 + 234 45 31 k_TF_dephos #Rule11 + 235 46 33 k_TF_dephos #Rule11 + 236 47 42 k_TF_dephos #Rule11 + 237 48 36 k_TF_dephos #Rule11 + 238 49 3 k_TF_dephos #Rule11 + 239 50 43 2*k_TF_dephos #Rule11 + 240 49,49 58 0.0012152573*kp_TF_TF #Rule12 unit_conversion=1/vol_CP + 241 17,53 57 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 242 26,53 52 0.29451533*kp_LR #Rule1 unit_conversion=1/vol_EN + 243 27,53 54 0.14725766*kp_LR #Rule1 unit_conversion=1/vol_EN + 244 28,53 55 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 245 38,53 47 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 246 18,52 57 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 247 29,52 55 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 248 39,52 47 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 249 52,53 56 34.25153*kp_LR #Rule1 unit_conversion=1/(sa_EM*eff_width) + 250 51 2,44 km_LR #_reverse_Rule1 + 251 51 11,45 km_LR #_reverse_Rule1 + 252 52 26,53 km_LR #_reverse_Rule1 + 253 54 27,53 km_LR #_reverse_Rule1 + 254 55 29,52 km_LR #_reverse_Rule1 + 255 55 28,53 km_LR #_reverse_Rule1 + 256 56 52,53 2*km_LR #_reverse_Rule1 + 257 57 18,52 km_LR #_reverse_Rule1 + 258 57 17,53 km_LR #_reverse_Rule1 + 259 21,54 57 34.25153*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 260 27,54 52 0.14725766*kp_LL #Rule2 unit_conversion=1/vol_EN + 261 32,54 55 34.25153*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 262 40,54 47 34.25153*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 263 54,54 56 17.125765*kp_LL #Rule2 unit_conversion=1/(sa_EM*eff_width) + 264 51 8,46 km_LL #_reverse_Rule2 + 265 52 27,54 km_LL #_reverse_Rule2 + 266 55 32,54 km_LL #_reverse_Rule2 + 267 56 54,54 km_LL #_reverse_Rule2 + 268 57 21,54 km_LL #_reverse_Rule2 + 269 51 57 k_R_endo #Rule3 + 270 52 44 k_recycle #Rule4 + 271 53 45 k_recycle #Rule4 + 272 54 46 k_recycle #Rule4 + 273 55 48 k_recycle #Rule4 + 274 56 50 k_recycle #Rule4 + 275 57 51 k_recycle #Rule4 + 276 51 48 k_R_transphos #Rule6 + 277 57 55 k_R_transphos #Rule6 + 278 55 57 k_R_dephos #Rule7 + 279 3,55 47 0.0024305147*kp_R_TF #Rule8 unit_conversion=1/vol_CP + 280 49,55 56 0.0024305147*kp_R_TFp #Rule9 unit_conversion=1/vol_CP + 281 51 15,49 km_R_TFp #_reverse_Rule9 + 282 52 28,49 km_R_TFp #_reverse_Rule9 + 283 53 29,49 km_R_TFp #_reverse_Rule9 + 284 54 32,49 km_R_TFp #_reverse_Rule9 + 285 55 34,49 km_R_TFp #_reverse_Rule9 + 286 56 49,55 2*km_R_TFp #_reverse_Rule9 + 287 57 23,49 km_R_TFp #_reverse_Rule9 + 288 51 25 k_TF_dephos #Rule11 + 289 52 38 k_TF_dephos #Rule11 + 290 53 39 k_TF_dephos #Rule11 + 291 54 40 k_TF_dephos #Rule11 + 292 55 41 k_TF_dephos #Rule11 + 293 56 47 2*k_TF_dephos #Rule11 + 294 57 35 k_TF_dephos #Rule11 + 295 58 49,49 km_TF_TF #_reverse_Rule12 + 296 5,58 59 0.0024305147*k_Im_bind_CP #Rule24 unit_conversion=1/vol_CP + 297 10,58 60 0.0024305147*k_Im_bind_CP #Rule24 unit_conversion=1/vol_CP + 298 59 5,58 k_Im_unbind_CP #_reverse_Rule24 + 299 60 10,58 k_Im_unbind_CP #_reverse_Rule24 + 300 6,59 60 0.0024305147*k_Im_enters_NP #Rule28 unit_conversion=1/vol_CP + 301 60 6,59 k_Im_exits_NP #_reverse_Rule28 + 302 60 61 k_Im_cross_NP #Rule29 + 303 61 13,62 k_Im_unbind_NU #_reverse_Rule25 + 304 61 6,63 k_Im_exits_NP #_reverse_Rule28 + 305 61 60 k_Im_cross_NP #_reverse_Rule29 + 306 62 64,64 km_TF_TF #_reverse_Rule12 + 307 4,62 65 0.0026436234*kp_TF_p1 #Rule13 unit_conversion=1/vol_NU + 308 13,62 61 0.0026436234*k_Im_bind_NU #Rule25 unit_conversion=1/vol_NU + 309 16,62 63 0.0026436234*k_Im_bind_NU #Rule25 unit_conversion=1/vol_NU + 310 63 16,62 k_Im_unbind_NU #_reverse_Rule25 + 311 6,63 61 0.0026436234*k_Im_enters_NP #Rule28 unit_conversion=1/vol_NU + 312 64,64 62 0.0013218117*kp_TF_TF #Rule12 unit_conversion=1/vol_NU + 313 65 4,62 km_TF_p1 #_reverse_Rule13 + 314 65 65,66 k_transcribe #Rule14 + 315 66 67 k_mRNA_to_CP #Rule16 + 316 66 7 k_mRNA_deg #Rule20 + 317 67 67,68 k_translate #Rule18 + 318 67 7 k_mRNA_deg #Rule20 + 319 68 7 k_P_deg #Rule22 + 320 5,68 69 0.0024305147*k_Im_bind_CP #Rule26 unit_conversion=1/vol_CP + 321 10,68 70 0.0024305147*k_Im_bind_CP #Rule26 unit_conversion=1/vol_CP + 322 69 5,7 k_P_deg #Rule22 + 323 70 7,10 k_P_deg #Rule22 + 324 69 5,68 k_Im_unbind_CP #_reverse_Rule26 + 325 70 10,68 k_Im_unbind_CP #_reverse_Rule26 + 326 6,69 70 0.0024305147*k_Im_enters_NP #Rule28 unit_conversion=1/vol_CP + 327 70 6,69 k_Im_exits_NP #_reverse_Rule28 + 328 70 71 k_Im_cross_NP #Rule29 + 329 71 7,13 k_P_deg #Rule22 + 330 71 13,72 k_Im_unbind_NU #_reverse_Rule27 + 331 71 6,73 k_Im_exits_NP #_reverse_Rule28 + 332 71 70 k_Im_cross_NP #_reverse_Rule29 + 333 72 7 k_P_deg #Rule22 + 334 73 7,16 k_P_deg #Rule22 + 335 13,72 71 0.0026436234*k_Im_bind_NU #Rule27 unit_conversion=1/vol_NU + 336 16,72 73 0.0026436234*k_Im_bind_NU #Rule27 unit_conversion=1/vol_NU + 337 73 16,72 k_Im_unbind_NU #_reverse_Rule27 + 338 6,73 71 0.0026436234*k_Im_enters_NP #Rule28 unit_conversion=1/vol_NU + 339 4,72 74 0.0026436234*kp_P1_p2 #Rule30 unit_conversion=1/vol_NU + 340 65,72 75 0.0026436234*kp_P1_p2 #Rule30 unit_conversion=1/vol_NU + 341 62,74 75 0.0026436234*kp_TF_p1 #Rule13 unit_conversion=1/vol_NU + 342 75 62,74 km_TF_p1 #_reverse_Rule13 + 343 75 66,75 k_transcribe #Rule14 + 344 74 74,76 k_transcribe #Rule15 + 345 75 75,76 k_transcribe #Rule15 + 346 74 4,7 k_P_deg #Rule22 + 347 75 7,65 k_P_deg #Rule22 + 348 74 4,72 km_P1_p2 #_reverse_Rule30 + 349 75 65,72 km_P1_p2 #_reverse_Rule30 + 350 76 77 k_mRNA_to_CP #Rule17 + 351 76 7 k_mRNA_deg #Rule21 + 352 77 77,78 k_translate #Rule19 + 353 77 7 k_mRNA_deg #Rule21 + 354 78 7 k_P_deg #Rule23 +end reactions +begin groups + 1 Tot_L 1,8,2*9,2*11,2*12,2*14,2*15,2*17,2*19,21,22,2*23,2*24,2*25,2*26,27,2*28,2*30,32,33,2*34,2*35,2*36,2*37,2*38,40,2*41,2*42,2*43,2*44,46,2*47,2*48,2*50,2*51,2*52,54,2*55,2*56,2*57 + 2 Tot_R 2,8,11,2*12,2*14,2*15,17,18,19,20,21,22,2*23,2*24,2*25,28,29,30,31,32,33,2*34,2*35,2*36,2*37,38,39,40,2*41,2*42,2*43,44,45,46,2*47,2*48,2*50,2*51,52,53,54,2*55,2*56,2*57 + 3 Tot_TF 3,25,30,31,33,35,36,2*37,38,39,40,41,2*42,2*43,44,45,46,2*47,48,49,2*50,51,52,53,54,55,2*56,57,2*58,2*59,2*60,2*61,2*62,2*63,64,2*65,2*75 + 4 Tot_DNA 4,65,74,75 + 5 Tot_mRNA1 66,67 + 6 Tot_mRNA2 76,77 + 7 Tot_P1 68,69,70,71,72,73,74,75 + 8 Tot_P2 78 + 9 Tot_NP 6,10,13,60,61,70,71 + 10 Tot_Im 5,10,13,16,59,60,61,63,69,70,71,73 + 11 L_Dimers_EC 9 + 12 L_Dimers_PM 11,12,15,19,24,25,30,36,37,43,44,48,50,51 + 13 L_Dimers_EN 26 + 14 L_Dimers_EM 14,17,23,28,34,35,38,41,42,47,52,55,56,57 + 15 L_Bound_PM 8,2*11,2*12,2*15,2*19,22,2*24,2*25,2*30,33,2*36,2*37,2*43,2*44,46,2*48,2*50,2*51 + 16 L_Bound_EM 2*14,2*17,21,2*23,2*28,32,2*34,2*35,2*38,40,2*41,2*42,2*47,2*52,54,2*55,2*56,2*57 + 17 R_Dimers_PM 12,15,24,25,36,37,43,48,50,51 + 18 R_Dimers_EM 14,23,34,35,41,42,47,55,56,57 + 19 Catalytic_R 15,19,20,22,23,2*24,25,28,29,30,31,32,33,2*34,35,2*36,2*37,38,39,40,2*41,2*42,2*43,44,45,46,2*47,2*48,2*50,51,52,53,54,2*55,2*56,57 + 20 Catalytic_TF 25,30,31,33,35,36,2*37,38,39,40,41,2*42,2*43,44,45,46,2*47,48,2*50,51,52,53,54,55,2*56,57 + 21 Phos_TF 43,44,45,46,47,48,49,2*50,51,52,53,54,55,2*56,57,2*58,2*59,2*60,2*61,2*62,2*63,64,2*65,2*75 + 22 TF_Dimer_CP 58,59,60 + 23 TF_Dimer_NU 61,62,63,65,75 + 24 Bound_prom1 65,75 + 25 Bound_prom2 74,75 + 26 P1_NU 71,72,73,74,75 + 27 P1_CP 68,69,70 + 28 Im_NU 13,16,61,63,71,73 + 29 Im_CP 5,10,59,60,69,70 + 30 Im_Cargo_NP 60,61,70,71 + 31 P1_NU_free 72 + 32 P1_NU_dna 74,75 + 33 CountSink 7 +end groups diff --git a/demos/3D/demo3D61/demo3D61.m b/demos/3D/demo3D61/demo3D61.m new file mode 100644 index 0000000..1aa1f70 --- /dev/null +++ b/demos/3D/demo3D61/demo3D61.m @@ -0,0 +1,153 @@ +function answer = demo3D61() +% demo3D61 +% +% Input +% ----- +% +% Output +% ------ +% * a valid model + +% Copyright (C) 2020 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D61' ); +disp( 'The estimated running time is approximately 90 minutes. Please wait.' ); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%Check if dir are present at every run & deletes them to avoid conflicts +% if exist('spharm_result', 'dir') +% warning('off'); +% rmdir('spharm_result', 's'); +% rmdir('spharm_input', 's'); +% rmdir('param','s'); +% end + +directory = '../../../images/HeLa/3D/processed'; +cell_paths = {}; dna_paths = {}; prot_paths = {}; options.labels = {}; +for i = 1:5 + dna_paths{i} = [directory filesep 'LAM_cell' num2str(i) '_ch0_t1.tif']; + cell_paths{i} = [directory filesep 'LAM_cell' num2str(i) '_ch1_t1.tif']; + prot_paths{i} = [directory filesep 'LAM_cell' num2str(i) '_ch2_t1.tif']; + options.labels{length(options.labels)+1} = 'LAMP2'; + options.masks{i} = [directory filesep 'LAM_cell' num2str(i) '_mask_t1.tif']; +end + +%set the dimensionality +dimensionality = '3D'; +resolution = [0.049, 0.049, 0.2000]; + +% parameters for spharm +options_spharm.verbose = true; +options_spharm.debug = ~false; + +%set this off as it's causing an error +%Ted 03/18/2020 +options_spharm.display = false; + +options_spharm = ml_initparam( options_spharm, struct( ... + 'train', struct( 'flag', 'cell' ))); +options_spharm.cell.class = 'cell_membrane'; +options_spharm.cell.type = 'spharm_rpdm'; + +% postprocess of parameterization: alignment +options_spharm.model.spharm_rpdm.postprocess = true; +options_spharm.model.resolution = resolution; +options_spharm.downsampling = [1,1,1]; % this is for the spharm modeling of objects +options_spharm.model.filename = 'objects.xml'; +options_spharm.model.id = 'objects'; +options_spharm.model.name = 'objects'; +options_spharm.nucleus.name = 'objects'; +options_spharm.cell.model = 'objects'; +% degree of the descriptor +options_spharm.model.spharm_rpdm.maxDeg = 31; +% cellular components: either {'cell'}, {'nuc'}, or {'cell', 'nuc'} +options_spharm.model.spharm_rpdm.components = {'cell'}; +% latent dimension for the model +options_spharm.model.spharm_rpdm.latent_dim = 15; +% alignment method: 'major_axis' or 'foe' +options_spharm.model.spharm_rpdm.alignment_method = 'major_axis'; +% plane of rotation: 'xy' 'yz', 'xz' or 'xyz' +options_spharm.model.spharm_rpdm.rotation_plane = 'xyz'; +%documentation +options_spharm.documentation.description = 'This model has been trained for shape-location protein model from CellOrganizer'; +options_spharm.model.spharm_rpdm.segminnucfraction = 0.1; +options_spharm.verbose = 1; +options_spharm.spharm_rpdm.NMcost_tol = 1e-7; +options_spharm.spharm_rpdm.NMlargr_tol = 1e-7; +options_spharm.spharm_rpdm.NMfirsttry_maxiter = 300; +options_spharm.spharm_rpdm.NMretry_maxiter = 100; +options_spharm.spharm_rpdm.NMretry_maxiterbig = 300; + +% setup_everything: +options.options_spharm = options_spharm; +options.verbose = 0; +%%% +options.train.flag = 'protein'; +%options.train.flag = ['framework', 'protein']; +%options.nucleus.class = 'nuclear_membrane'; +%options.nucleus.type = 'spharm_rpdm'; +%options.cell.class = 'cell_membrane'; +%options.cell.type = 'spharm_rpdm'; +%%% +options.protein.class = 'vesicle'; +options.protein.type = 'spharm_obj'; % new type for vesicle +options.model.id = uuidgen(); +options.model.name = 'LAMP2spharm_obj'; +options.model.resolution = resolution; +%options.downsampling = [4,4,1]; +options.downsampling = [1,1,1]; %this is for the initial input images +options.min_obj_size = 20; +options.max_obj_size = 400; +%options_ppm.min_obj_size=7; +options.local_thresholding_sigma = 5; +options.object_detection_thresPerc = 0.1; +%options.masks = mask_paths; +%options.if_skip_cell_nuclear_model = true; +options.if_skip_cell_nuclear_model = false; + +tic; answer = img2slml(dimensionality, dna_paths, cell_paths, prot_paths , options ); toc, + +options = []; +options.shape_evolution = 'none'; +options.labels = 'unique'; +options.subsize = 100; % smaller number means bigger objects +options.viewangle = [0,90]; %down z axis +%options.viewangle = [90,0]; %side view +options.hd_threshold = 10.; % filter out objects with Hausdorff distance greater than this +slml2info({'model.mat'},options); + +load('model.mat'); +%f = figure('visible','off'); +f = figure('visible','on'); +hist(log10(model.proteinModel.spharm_obj_model.cellShapeModel.hausdorff_distances),25) +xlabel('Log10 Hausdorff distance between original and SPHARM-RPDM model'); +ylabel('Frequency') +saveas( f, 'hausdorff_distance_histogram.png', 'png' ); diff --git a/demos/3D/demo3D62/demo3D62.m b/demos/3D/demo3D62/demo3D62.m new file mode 100644 index 0000000..cbfb63a --- /dev/null +++ b/demos/3D/demo3D62/demo3D62.m @@ -0,0 +1,145 @@ +function answer = demo3D62() +% demo3D62 +% +% construct subcellular object shape and distribution models using images +% from Allen Institute for Cell Science +% +% Input +% ----- +% +% Output +% ------ +% * a valid model + +% Copyright (C) 2021 Murphy Lab +% Computational Biology Department +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( 'demo3D62' ); +disp( 'The estimated running time is approximately 90 minutes. Please wait.' ); +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%Check if dir are present at every run & deletes them to avoid conflicts +% if exist('spharm_result', 'dir') +% warning('off'); +% rmdir('spharm_result', 's'); +% rmdir('spharm_input', 's'); +% rmdir('param','s'); +% end + +directory=strcat(current_path,'../../../images/AICS/Allen_Institute_Images_1'); +cell_paths = {}; dna_paths = {}; prot_paths = {}; options.labels = {}; +for i = 1:length(directory) + cell_paths{i} = [directory filesep 'segmentedcell' num2str(i) '.tif']; + dna_paths{i} = [directory filesep 'segmenteddna' num2str(i) '.tif']; + prot_paths{i} = [directory filesep 'protein' num2str(i) '.tif']; + options.labels{length(options.labels)+1} = 'Mitochondria'; + options.masks{i} = [directory filesep 'mask' num2str(i) '.tif']; +end + +%set the dimensionality of the model +dimensionality = '3D'; +resolution = [0.108, 0.108, 0.29]; + + +% parameters for spharm +options_spharm.verbose = true; +options_spharm.debug = ~false; + +%set this off as it's causing an error +%Ted 03/18/2020 +options_spharm.display = false; + +options_spharm = ml_initparam( options_spharm, struct( ... + 'train', struct( 'flag', 'cell' ))); +options_spharm.cell.class = 'cell_membrane'; +options_spharm.cell.type = 'spharm_rpdm'; + +% postprocess of parameterization: alignment +options_spharm.model.spharm_rpdm.postprocess = true; +options_spharm.model.resolution = resolution; +options_spharm.downsampling = [1,1,1]; +options_spharm.model.filename = 'objects.xml'; +options_spharm.model.id = 'objects'; +options_spharm.model.name = 'objects'; +options_spharm.nucleus.name = 'objects'; +options_spharm.cell.model = 'objects'; +% degree of the descriptor +options_spharm.model.spharm_rpdm.maxDeg = 31; +% cellular components: either {'cell'}, {'nuc'}, or {'cell', 'nuc'} +options_spharm.model.spharm_rpdm.components = {'cell'}; +% latent dimension for the model +options_spharm.model.spharm_rpdm.latent_dim = 15; +% alignment method: 'major_axis' or 'foe' +options_spharm.model.spharm_rpdm.alignment_method = 'major_axis'; +% plane of rotation: 'xy' 'yz', 'xz' or 'xyz' +options_spharm.model.spharm_rpdm.rotation_plane = 'xyz'; +%documentation +options_spharm.documentation.description = 'This model has been trained for shape-location protein model from CellOrganizer'; +options_spharm.model.spharm_rpdm.segminnucfraction = 0.1; +options_spharm.verbose = 1; +options_spharm.spharm_rpdm.NMcost_tol = 1e-7; +options_spharm.spharm_rpdm.NMlargr_tol = 1e-7; +options_spharm.spharm_rpdm.NMfirsttry_maxiter = 300; +options_spharm.spharm_rpdm.NMretry_maxiter = 100; +options_spharm.spharm_rpdm.NMretry_maxiterbig = 300; + +% setup_everything: +options.options_spharm = options_spharm; +options.verbose = 0; +options.train.flag = 'protein'; +options.protein.class = 'vesicle'; +options.protein.type = 'spharm_obj'; % new type for vesicle +options.model.id = uuidgen(); +options.model.name = 'spharm_obj'; +options.model.resolution = resolution; +options.downsampling = [1,1,1]; +options.min_obj_size = 10; +options.max_obj_size = 400; +%options.masks = mask_paths; +options.if_skip_cell_nuclear_model = false; + +tic; answer = img2slml(dimensionality, dna_paths, cell_paths, prot_paths , options ); toc, + +options = []; +options.shape_evolution = 'none'; +options.labels = 'unique'; +options.subsize = 100; % smaller number means bigger objects +options.viewangle = [0,90]; %down z axis +%options.viewangle = [90,0]; %side view +options.hd_threshold = 10.; % filter out objects with Hausdorff distance greater than this +slml2info({'model.mat'},options); + +load('model.mat'); +%f = figure('visible','off'); +f = figure('visible','on'); +hist(log10(model.proteinModel.spharm_obj_model.cellShapeModel.hausdorff_distances),25) +xlabel('Log10 Hausdorff distance between original and SPHARM-RPDM model'); +ylabel('Frequency') +saveas( f, 'hausdorff_distance_histogram.png', 'png' ); diff --git a/demos/3D/demo3D63/demo3D63.m b/demos/3D/demo3D63/demo3D63.m new file mode 100644 index 0000000..a16dce2 --- /dev/null +++ b/demos/3D/demo3D63/demo3D63.m @@ -0,0 +1,108 @@ +function answer = demo3D63( options ) +% demo3D63 +% +% Synthesize one 3D image with nuclear and cell shape channels using the +% SPHARM framework model and combine with reaction network in VCML format +% into a single VCML file. +% +% Input +% ----- +% * a valid CellOrganizer model +% * one or more valid VCML reaction network models with Virtual Cell's +% default units +% +% Output +% ------ +% * VCML file +% * single channel TIF files + +% Author: Ivan E. Cao-Berg, Taraz Buck +% +% Copyright (C) 2016-2020 Murphy Lab +% Lane Center for Computational Biology +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +% The framework (cell and nucleus shapes) will be synthesized using framework_model +framework_model = '../../../models/3D/spharm/lamp2.mat'; +reaction_network_file = '../../../data/SarmaGhosh2012ForCOdiff1e-2.vcml'; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +start_time = tic; +start_cputime = cputime; +disp( mfilename ); +disp( 'The estimated running time is about 3 minutes. Please wait.' ); + +options.seed = 741332; +options.targetDirectory = pwd; +options.prefix = 'img'; +options.synthesis = 'framework'; +options.model.spharm_rpdm.synthesis_method = 'random_sampling'; +options.model.spharm_rpdm.imageSize = [512, 512, 36]; +options.model.spharm_rpdm.synthesis_resolution = [0.10 0.10 0.1]; +options.numberOfSynthesizedImages = 1; + +options.compression = 'lzw'; +options.microscope = 'none'; +options.sampling.method = 'disc'; +options.verbose = true; +options.debug = false; +options.output.tifimages = true; +options.output.OMETIFF = true; +options.output.indexedimage = true; + +% VCML Options +options.output.VCML.writeVCML = true; +options.VCML.downsampling = 1/2; +options.VCML.translations = {'cell', 'CP'; 'nuc', 'NU'; ... + 'nucleus', 'NU'; 'lamp2_mat_tfr_mat', 'EN'; 'CP_EC', 'PM'; ... + 'CP_EN', 'EM'; 'CP_NU', 'NM'}; + +options.VCML.input_filename = reaction_network_file; +options.NET.useImageAdjacency = false; + +options.VCML.default_time_step = 1e0; +options.VCML.end_time = 4000; +options.VCML.output_time_step = 100; +options.VCML.max_time_step = 4; +options.VCML.absolute_tolerance = 1e-8; +options.VCML.relative_tolerance = 1e-8; + +try + state = rng( options.seed ); +catch err + rand( 'seed', options.seed ); %#ok +end + +% Synthesize Image and VCML file +answer = slml2img( { framework_model }, options ); +end diff --git a/demos/3D/demo3D64/demo3D64.m b/demos/3D/demo3D64/demo3D64.m new file mode 100644 index 0000000..c92bdb3 --- /dev/null +++ b/demos/3D/demo3D64/demo3D64.m @@ -0,0 +1,321 @@ +function answer = demo3D64( options ) +% demo3D64 +% +% Synthesize one 3D image with nuclear, cell shape and a vesicular channel and +% test SBML Spatial export options by saving files for multiple combinations of +% settings. +% +% Input +% ----- +% * a valid CellOrganizer model +% +% Output +% ------ +% * 20 SBML instances (`demo3D64/*.xml`) +% * Filenames indicate a combination of SBML Spatial-related options: +% * `_SpatialUseAnalyticMeshes` in a filename means +% `options.output.SBMLSpatialUseAnalyticMeshes = true` +% * `_SpatialImage` means `options.output.SBMLSpatialImage = true` +% * `_SpatialVCellCompatible` means +% `options.output.SBMLSpatialVCellCompatible = true` +% * `_SpatialUseCompression` means +% `options.output.SBMLSpatialUseCompression = true` +% * `_primitives` means `options.output.primitives = true` +% * Not all options or combinations of options are intended for the end user. +% We recommend using: +% * Only `options.output.SBMLSpatialUseAnalyticMeshes = true` if you need +% geometry in triangle mesh format. We are working on this being +% CellBlender compatible. +% * Only `options.output.SBMLSpatialImage = true` if you need geometry in +% image format. +% * Not all combinations of options will produce valid SBML output. +% * `options.output.SBMLSpatialVCellCompatible = true` attempts to format +% output to be opened in Virtual Cell. Output will not necessarily be +% valid SBML. +% * Not all combinations of options will produce valid SBML Spatial output. +% * `options.output.SBMLSpatialUseAnalyticMeshes = false` uses Matlab's +% `isosurface`, which does not guarantee manifold, watertight meshes. +% This sometimes leads to invalid SBML Spatial when there are duplicate +% faces, for example. +% * single channel TIF files + +% Author: Ivan E. Cao-Berg, Taraz Buck +% +% Copyright (C) 2016-2020 Murphy Lab +% Lane Center for Computational Biology +% School of Computer Science +% Carnegie Mellon University +% +% 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 should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +% 02110-1301, USA. +% +% For additional information visit http://murphylab.web.cmu.edu or +% send email to murphy@cmu.edu + +use_profiling = false; +% use_profiling = true; + + +% Debug flag defaults +debug_recompute_finished_sets = false; +debug_allow_exceptions = false; +debug_options_sets_prefixes = {}; +debug_skip_vcell_compatible = false; + + +% Debug flags +debug_recompute_finished_sets = true; +debug_allow_exceptions = true; +% debug_skip_vcell_compatible = true; + + +% Print debug flags +debug_recompute_finished_sets +debug_allow_exceptions +debug_options_sets_prefixes + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% DO NOT MODIFY THIS BLOCK +start_time = tic; +start_cputime = cputime; + +if ~isdeployed() + current_path = which(mfilename); + [current_path, filename, extension] = fileparts( current_path ); + cd(current_path); +end + +disp( mfilename ); +disp( 'The estimated running time is about 9 minutes. Please wait.' ); + +options_base.seed = 12345; +options_base.targetDirectory = pwd; +options_base.numberOfSynthesizedImages = 20; +options_base.numberOfGaussianObjects = 5; +options_base.prefix = 'img'; +options_base.compression = 'lzw'; +options_base.microscope = 'none'; +options_base.sampling.method = 'disc'; +options_base.verbose = true; +options_base.debug = false; +options_base.output.tifimages = true; +options_base.output.indexedimage = true; +% options_base.overwrite_synthetic_instances = false; +options_base.rendAtStd = 1.0; +options_base.objstd = options_base.rendAtStd+0.3; +% options_base.overlapsubsize = 1; +% options_base.output.SBML = true; +options_base.output.SBMLSpatial = true; +options_base.output.SBMLSpatialImage = false; +options_base.output.SBMLSpatialUseAnalyticMeshes = false; +% options_base.output.SBMLDownsampling = 1/4; +options_base.output.SBMLDownsampling = [1/16, 1/16, 1]; +% options_base.output.SBMLSpatialVCellCompatible = true; +options_base.output.SBMLSpatialUseCompression = false; +options_base.SBML.translations = {'cell', 'CP'; 'nucleus', 'NU'; 'nuc', 'NU'; 'tfr_mat', 'EN'; 'CP_EC', 'PM'; 'CP_EN', 'EM'; 'CP_NU', 'NM'}; +options_base.output.primitives = false; +% options_base.output.OMETIFF = true; + + +% 'cell' and 'nucleus' options unneeded +options_synthesis_choices = {'framework', 'all'}; + +shape_format_choices = {'analyticMesh', 'image', 'isosurface'}; + +options_sets = {}; + +ks = [false, true]; +if debug_skip_vcell_compatible + ks = [false]; +end + +options = options_base; +for i = 1:length(options_synthesis_choices) + options.synthesis = options_synthesis_choices{i}; +for j = 1:length(shape_format_choices) + options.output.SBMLSpatialUseAnalyticMeshes = false; + options.output.SBMLSpatialImage = false; + options.output.primitives = false; + switch shape_format_choices{j} + case 'analyticMesh' + options.output.SBMLSpatialUseAnalyticMeshes = true; + case 'image' + options.output.SBMLSpatialImage = true; + case 'isosurface' + % Do nothing + case 'primitives' + options.output.primitives = true; + otherwise + % Do nothing + end +for k = ks + options.output.SBMLSpatialVCellCompatible = k; +for m = [false, true] + options.output.SBMLSpatialUseCompression = m; + + if options.output.primitives && (options.output.SBMLSpatialImage || any(strcmp(options.synthesis, {'cell', 'nucleus', 'framework'}))) + continue; + end + + options.prefix = options.synthesis; + options_sets{end+1} = options; + +end +end +end +end + + +% Create a unique prefix for each options set +for i = 1:length(options_sets) + options = options_sets{i}; + options.prefix = options.synthesis; + if options.output.SBMLSpatialUseAnalyticMeshes + options.prefix = [options.prefix, '_SpatialUseAnalyticMeshes']; + end + if options.output.SBMLSpatialImage + options.prefix = [options.prefix, '_SpatialImage']; + end + if options.output.SBMLSpatialVCellCompatible + options.prefix = [options.prefix, '_SpatialVCellCompatible']; + end + if options.output.SBMLSpatialUseCompression + options.prefix = [options.prefix, '_SpatialUseCompression']; + end + if options.output.primitives + options.prefix = [options.prefix, '_primitives']; + end + options_sets{i} = options; +end + + +options_sets_prefixes = cellfun(@(x)x.prefix, options_sets, 'UniformOutput', false); +options_sets_prefixes = options_sets_prefixes'; +options_sets_prefixes + +if length(debug_options_sets_prefixes) > 0 + options_sets2_prefixes = debug_options_sets_prefixes; +else + options_sets2_prefixes = options_sets_prefixes; +end + + +if size(options_sets2_prefixes, 2) > 1 + options_sets2_prefixes = options_sets2_prefixes'; +end +options_sets2_prefixes + +options_sets2 = {}; +for i = 1:length(options_sets) + if any(strcmp(options_sets{i}.prefix, options_sets2_prefixes)) + options_sets2{end+1} = options_sets{i}; + end +end +options_sets = options_sets2; +options_sets_count = length(options_sets) + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% FEEL FREE TO MODIFY THE VARIABLES IN THIS BLOCK + +% note, the framework will be synthesized using the first protein model +% found to match the given patterns in the SBML file. +% Changing the order/priority of this is not supported at this time. +list_of_models = {'../../../models/3D/tfr.mat'}; +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function iteration(given_options_set, given_xml_source_filename, given_xml_destination_filename, given_xml_source_zip_filename, given_xml_destination_zip_filename, given_png_source_filename, given_png_destination_filename) + if use_profiling + profile off; profile('-memory','on'); profile off; profile on; + end + + try + state = rng( given_options_set.seed ); + catch err + rand( 'seed', given_options_set.seed ); %#ok + end + + answer = slml2img( list_of_models, given_options_set ); + + copyfile(given_xml_source_filename, given_xml_destination_filename); + copyfile(given_xml_source_zip_filename, given_xml_destination_zip_filename); + copyfile(given_png_source_filename, given_png_destination_filename); + + if use_profiling + profile_results = profile('info'); + profile_filename = [given_options_set.prefix, '_profile_results', '.mat']; + profsave(profile_results, [profile_filename, '_html']); + save(profile_filename, 'profile_results'); + end + + %{ + try + [sbml_valid, sbml_problems] = validate_SBML_instance(xml_destination_filename, true) + % [sbml_valid, sbml_problems] = validate_SBML_instance(xml_source_zip_filename, true) + catch ME + warning('Caught exception:'); + getReport(ME) + end + %} +end + +for i = 1:length(options_sets) + options_set = options_sets{i} + options_set_output = options_set.output + + xml_source_filename = [options_set.prefix, '/cell1/cell.xml']; + xml_destination_filename = [options_set.prefix, '.xml']; + xml_source_zip_filename = [xml_source_filename, '.zip']; + xml_destination_zip_filename = [xml_destination_filename, '.zip']; + png_source_filename = [options_set.prefix, '/cell1/indexed.png']; + png_destination_filename = [options_set.prefix, '.png']; + xml_destination_validation_filename = [xml_destination_filename, '.validationresults.xml']; + % xml_destination_zip_filename = [xml_destination_zip_filename, '.validationresults.xml']; + + % if exist(xml_destination_validation_filename, 'file') && ~debug_recompute_finished_sets + if exist(xml_destination_filename, 'file') && ~debug_recompute_finished_sets + % Do not repeat work + continue; + end + + iteration_handle = @()iteration(options_set, xml_source_filename, xml_destination_filename, xml_source_zip_filename, xml_destination_zip_filename, png_source_filename, png_destination_filename); + + if debug_allow_exceptions + iteration_handle(); + else + try + iteration_handle(); + catch ME + warning('Caught exception:'); + getReport(ME) + % delete(xml_destination_filename); + % delete(xml_destination_zip_filename); + if exist(xml_destination_validation_filename, 'file') + delete(xml_destination_validation_filename); + end + end + end +end + +% Create table of features and SBML validity + +elapsed_time = toc(start_time); +elapsed_cputime = cputime - start_cputime; +fprintf('\n%s took %.3f s (%.3f s CPU time)\n\n', mfilename, elapsed_time, elapsed_cputime); + +end%demo3D64