如何检索指定对象的文件信息。从Matlab到Python的转换

如何检索指定对象的文件信息。从Matlab到Python的转换,python,matlab,Python,Matlab,我需要了解如何在Python中检索指定对象的文件信息。具体地说,我正在尝试将下面的Matlab代码的第4部分转换为Python。但是,关于如何检索文件信息的任何帮助都会有所帮助 %% Section 1: Set path to 'Tomography Crops' folder %--Set folder containing the cropped tomography data %----Should be named 'Tomography Crops' if script 'crop

我需要了解如何在Python中检索指定对象的文件信息。具体地说,我正在尝试将下面的Matlab代码的第4部分转换为Python。但是,关于如何检索文件信息的任何帮助都会有所帮助

%% Section 1: Set path to 'Tomography Crops' folder

%--Set folder containing the cropped tomography data
%----Should be named 'Tomography Crops' if script 'crop_insitu_images.m' was
%----used for cropping 
crop_datDir = uigetdir([],'Select folder containing cropped in-situ data for the desired 
work order/build');
if ~isfolder(crop_datDir)
    errorMessage = sprintf('Error: The following folder does not exist:\n%s\nPlease specify 
a new folder.', data_dir);
    uiwait(warndlg(errorMessage));
    crop_datDir = uigetdir(); %-Ask for a new one.
    if crop_datDir == 0
         %-User clicked Cancel
         return;
    end
end

%--Add the sort_nat function to the Matlab path
sort_func = what('sort_nat'); %-Find characteristics
sort_funcPath = addpath(sort_func.path); %-Store and add to matlab path

%% Section 2: Have user specify object for analysis from list

%--Retrieve/store names of object folders
obj_dir = [crop_datDir '\obj*'];
obj_fldrs = dir(obj_dir);
obj_names = {obj_fldrs.name};

%--Present user with list to select object for analysis
[obj_indx,~] = listdlg('ListString',obj_names,'SelectionMode','single',...
    'PromptString','Select object for analysis')

%--Store object object folder name from user input
obj_num = char(obj_names(obj_indx));

%% Section 3: Have user specify upper/lower limit for reference layers

%--Specify the lower limit for reference layers to be used in analysis
min_refLyrMsg = 'Enter the lower limit for reference layers to be used in analysis';
min_refLyrDlg = inputdlg(min_refLyrMsg);
min_refLyrChar = char(min_refLyrDlg); %-Convert input to numeric format

%--Specify the upper limit for reference layers to be used in analysis 
max_refLyrMsg = 'Enter the upper limit for reference layers to be used in analysis';
max_refLyrDlg = inputdlg(max_refLyrMsg);
max_refLyrChar = char(max_refLyrDlg); %-Convert input to numeric format

%% Section 4: Retrieve file information for specified object

objX_dir = [crop_datDir '\' obj_num '\'];
objTmgrph_filePtrn = fullfile(objX_dir, 'Layer*.tif');
tmgrphFiles = dir(objTmgrph_filePtrn);
tmgrphFiles_names = {tmgrphFiles.name};
tmgrphFrm_num = length(tmgrphFiles_names);
[Cs_tmgrphDat ~] = sort_nat(tmgrphFiles_names);
min_refLyr = find(contains(Cs_tmgrphDat,['Layer (' min_refLyrChar ').tif'])); 
max_refLyr = find(contains(Cs_tmgrphDat,['Layer (' max_refLyrChar ').tif'])); 
seeded_defLyr = find(contains(Cs_tmgrphDat,'Layer (2599).tif'));