Changeset 6924


Ignore:
Timestamp:
09/14/10 12:06:32 (9 years ago)
Author:
curtis
Message:

Use line comments for proper function documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/utils/bfopen.m

    r6848 r6924  
    11function [result] = bfopen(id) 
    2  
    3 %{ 
    4 A script for opening microscopy images in MATLAB using Bio-Formats. 
    5  
    6 The function returns a list of image series; i.e., a cell array of cell 
    7 arrays of (matrix, label) pairs, with each matrix representing a single 
    8 image plane, and each inner list of matrices representing an image 
    9 series. See below for examples of usage. 
    10  
    11 Portions of this code were adapted from: 
    12 http://www.mathworks.com/support/solutions/data/1-2WPAYR.html?solution=1-2WPAYR 
    13  
    14 This method is ~1.5x-2.5x slower than Bio-Formats's command line 
    15 showinf tool (MATLAB 7.0.4.365 R14 SP2 vs. java 1.6.0_20), 
    16 due to overhead from copying arrays. 
    17  
    18 Thanks to all who offered suggestions and improvements: 
    19     * Ville Rantanen 
    20     * Brett Shoelson 
    21     * Martin Offterdinger 
    22     * Tony Collins 
    23     * Cris Luengo 
    24     * Arnon Lieber 
    25  
    26 NB: Internet Explorer sometimes erroneously renames the Bio-Formats library 
    27     to loci_tools.zip. If this happens, rename it back to loci_tools.jar. 
    28  
    29 Here are some examples of accessing data using the bfopen function: 
    30  
    31     % read the data using Bio-Formats 
    32     data = bfopen('C:/data/experiment.lif'); 
    33  
    34     % unwrap some specific image planes from the result 
    35     numSeries = size(data, 1); 
    36     series1 = data{1, 1}; 
    37     series2 = data{2, 1}; 
    38     series3 = data{3, 1}; 
    39     metadataList = data{1, 2}; 
    40     % ...etc. 
    41     series1_numPlanes = size(series1, 1); 
    42     series1_plane1 = series1{1, 1}; 
    43     series1_label1 = series1{1, 2}; 
    44     series1_plane2 = series1{2, 1}; 
    45     series1_label2 = series1{2, 2}; 
    46     series1_plane3 = series1{3, 1}; 
    47     series1_label3 = series1{3, 2}; 
    48     % ...etc. 
    49  
    50     % plot the 1st series's 1st image plane in a new figure 
    51     series1_colorMaps = data{1, 3}; 
    52     figure('Name', series1_label1); 
    53     if isempty(series1_colorMaps{1}) 
    54         colormap(gray); 
    55     else 
    56         colormap(series1_colorMaps{1}); 
    57     end 
    58     imagesc(series1_plane1); 
    59  
    60     % Or if you have the image processing toolbox, you could use: 
    61     % imshow(series1_plane1, []); 
    62  
    63     % Or animate as a movie (assumes 8-bit unsigned data) 
    64     v = linspace(0, 1, 256)'; 
    65     cmap = [v v v]; 
    66     for p = 1:series1_numPlanes 
    67         M(p) = im2frame(uint8(series1{p, 1}), cmap); 
    68     end 
    69     movie(M); 
    70  
    71     % Query some metadata fields (keys are format-dependent) 
    72     subject = metadataList.get('Subject'); 
    73     title = metadataList.get('Title'); 
    74 %} 
     2% A script for opening microscopy images in MATLAB using Bio-Formats. 
     3% 
     4% The function returns a list of image series; i.e., a cell array of cell 
     5% arrays of (matrix, label) pairs, with each matrix representing a single 
     6% image plane, and each inner list of matrices representing an image 
     7% series. See below for examples of usage. 
     8% 
     9% Portions of this code were adapted from: 
     10% http://www.mathworks.com/support/solutions/en/data/1-2WPAYR/ 
     11% 
     12% This method is ~1.5x-2.5x slower than Bio-Formats's command line 
     13% showinf tool (MATLAB 7.0.4.365 R14 SP2 vs. java 1.6.0_20), 
     14% due to overhead from copying arrays. 
     15% 
     16% Thanks to all who offered suggestions and improvements: 
     17%     * Ville Rantanen 
     18%     * Brett Shoelson 
     19%     * Martin Offterdinger 
     20%     * Tony Collins 
     21%     * Cris Luengo 
     22%     * Arnon Lieber 
     23%     * Jimmy Fong 
     24% 
     25% NB: Internet Explorer sometimes erroneously renames the Bio-Formats library 
     26%     to loci_tools.zip. If this happens, rename it back to loci_tools.jar. 
     27% 
     28% Here are some examples of accessing data using the bfopen function: 
     29% 
     30%     % read the data using Bio-Formats 
     31%     data = bfopen('C:/data/experiment.lif'); 
     32% 
     33%     % unwrap some specific image planes from the result 
     34%     numSeries = size(data, 1); 
     35%     series1 = data{1, 1}; 
     36%     series2 = data{2, 1}; 
     37%     series3 = data{3, 1}; 
     38%     metadataList = data{1, 2}; 
     39%     % ...etc. 
     40%     series1_numPlanes = size(series1, 1); 
     41%     series1_plane1 = series1{1, 1}; 
     42%     series1_label1 = series1{1, 2}; 
     43%     series1_plane2 = series1{2, 1}; 
     44%     series1_label2 = series1{2, 2}; 
     45%     series1_plane3 = series1{3, 1}; 
     46%     series1_label3 = series1{3, 2}; 
     47%     % ...etc. 
     48% 
     49%     % plot the 1st series's 1st image plane in a new figure 
     50%     series1_colorMaps = data{1, 3}; 
     51%     figure('Name', series1_label1); 
     52%     if isempty(series1_colorMaps{1}) 
     53%         colormap(gray); 
     54%     else 
     55%         colormap(series1_colorMaps{1}); 
     56%     end 
     57%     imagesc(series1_plane1); 
     58% 
     59%     % Or if you have the image processing toolbox, you could use: 
     60%     % imshow(series1_plane1, []); 
     61% 
     62%     % Or animate as a movie (assumes 8-bit unsigned data) 
     63%     v = linspace(0, 1, 256)'; 
     64%     cmap = [v v v]; 
     65%     for p = 1:series1_numPlanes 
     66%         M(p) = im2frame(uint8(series1{p, 1}), cmap); 
     67%     end 
     68%     movie(M); 
     69% 
     70%     % Query some metadata fields (keys are format-dependent) 
     71%     subject = metadataList.get('Subject'); 
     72%     title = metadataList.get('Title'); 
    7573 
    7674% -- Configuration - customize this section to your liking -- 
Note: See TracChangeset for help on using the changeset viewer.