import multiple .tiff images into a structure, with fields of "filename" and "resolution (pixels)" (512,512,121) for example.), and a user inputed "pixel size (um)" field (1.07,1.07,5) for example in matlab

To import multiple .tiff images into a structure with the specified fields, we can use the dir function to obtain a list of all .tiff files in a folder, and then loop through this list to read each file and store its information in the structure. We can use the imfinfo function to obtain the resolution of each image, and then create the structure with the specified fields.

Here's an example code that accomplishes this:

main.m
% Set folder and file extension
folder = 'path/to/folder';
fileExt = '*.tiff';

% Get list of files in folder
fileList = dir(fullfile(folder, fileExt));

% Loop through each file and store information in structure
for i = 1:length(fileList)
    % Get file information
    fileInfo = imfinfo(fullfile(folder, fileList(i).name));
    
    % Store filename and resolution in structure
    imageStruct(i).filename = fileList(i).name;
    imageStruct(i).resolution = [fileInfo.Width, fileInfo.Height, numel(fileInfo)];
    
    % Prompt user for pixel size and store in structure
    prompt = sprintf('Enter pixel size (um) for image %s: ', fileList(i).name);
    imageStruct(i).pixelSize = input(prompt);
end
705 chars
21 lines

This code creates a structure called imageStruct that contains fields for the filename, resolution, and pixel size for each image. The resolution field is a 3-element vector containing the width, height, and number of images (in the case of multi-page tiff files). The pixelSize field is obtained from user input for each image.

Note that this code assumes that all .tiff files in the specified folder have the same dimensions. If this is not the case, additional error checking and handling may be necessary.

gistlibby LogSnag