Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save Data #27

Open
KrystalR opened this issue Mar 28, 2018 · 11 comments
Open

Save Data #27

KrystalR opened this issue Mar 28, 2018 · 11 comments
Assignees

Comments

@KrystalR
Copy link

Hi,
When I try to use the function, PTKSaveAs, to save the data, it always shows that Undefined function or variable 'PTKSaveAs'. Even when I try to do doc PTKSaveAs, it always shows that No results for PTKSaveAs. Is there any way to save the data into mhd file or nii file without using GUI.

@tomdoel
Copy link
Owner

tomdoel commented Apr 3, 2018

Hi,
PTKSaveAs() has been replaced with MimSaveAs().

Did you see a reference to PTKSaveAs() in a tutorial or documentation somewhere? If so I would like to update it. Thanks.

@KrystalR
Copy link
Author

KrystalR commented Apr 4, 2018

Thank you for responding. I actually found this function on the document, tutorial 3.

@tomdoel
Copy link
Owner

tomdoel commented Apr 11, 2018

Thanks, I will update the tutorial. I think MimSaveAs() takes some additional parameters compared to PTKSaveAs() but they are not used unless saving as Dicom. But I will update the tutorial accordingly.

@tomdoel tomdoel self-assigned this Apr 20, 2018
@yahale
Copy link

yahale commented Oct 1, 2024

@tomdoel I am trying to find where I can change the output directory for exporting the data.
Currently it creates a folder inside the output folder with Patient Name as folder name. Can I change that into patient ID instead for example ? Since patient name is not unique and data can be replaced for 2 patients with same name. I've already read the "PTKSaveLungAnalysisResults" function but couldn't find anything related to changing the export process. Appreciate your help.

@yahale
Copy link

yahale commented Oct 1, 2024

I checked the below in 'PTKSaveLungAnalysisResults':

dataset.SaveTableAsCSV('PTKSaveLungAnalysisResults', 'Lung analysis', 'LungResults', 'Analysis for both lungs and individual lungs', table, MimResultsTable.PatientDim, MimResultsTable.ContextDim, MimResultsTable.MetricDim, []);

But it declares the name of subfolder, nothing about the folder name itself which seems the patient name by default.

@tomdoel
Copy link
Owner

tomdoel commented Oct 3, 2024

Hi, there is a CreateNewOutputFolder() method in the class MimOutputFolder. This chooses the output subfolder based on the image metadata - the patient name if it exists, otherwise it uses the patient id, and if that doesn't exist it tries other metadata. You should be able to modify that to set whatever output folder you need.

            if isfield(metadata, 'PatientName')
                [~, subfolder] = DMUtilities.PatientNameToString(metadata.PatientName);
            elseif isfield(metadata, 'PatientId')
                subfolder = metadata.PatientId;
            else
                subfolder = '';
            end

@yahale
Copy link

yahale commented Oct 6, 2024

Thanks @tomdoel , already tried it (saw it on another thread), and kept only the line of "PatientId", but still it is creating the sub folder by Name. Although I did not find any link to that function from the main running file.

@tomdoel
Copy link
Owner

tomdoel commented Oct 7, 2024

@yahale You'll need to restart Matlab (or else close PTK and clear all classes) because the output folder locations are cached in memory for the rest of the Matlab session,

Or you could modify the GetOutputPath() method in MimOutputFolder.m. You'll see that this method is called whenever a file is saved to the output folder. (You could put in a breakpoint to confirm this.) There is one MimOutputFolder class object for each dataset, and the first time (in a Matlab session) GetOutputPath() is called for that dataset, it calls CreateNewOutputFolder() to set the output folder. After that it uses the cached value in the obj.OutputFolder variable.

@yahale
Copy link

yahale commented Oct 16, 2024

Thanks @tomdoel . It worked after I deleted the main folder as you mentioned.
Is there a reference for the formulas used to calculate the output values in the lung analysis csv file ?
Tried to find them in your thesis but didn't find any.

@tomdoel
Copy link
Owner

tomdoel commented Oct 20, 2024

The computation of most of the outputs should be described in
KS Burrowes‚ T Doel‚ M Kim‚ C Vargas‚ J Roca‚ V Grau and D Kay: A combined image-modelling approach assessing the impact of hyperinflation due to emphysema on regional ventilation–perfusion matching. Computer Methods in Biomechanics and Biomedical Engineering: Imaging & Visualization 04/2015; DOI: 10.1080/21681163.2015.1023358

I think the outputs are computed in the following three functions, and combined into the output csv file:

  • Library/Analysis/PTKComputeAirTissueFraction.m - computes density from the HU values using a simple scaling and estimates the air/tissue fraction
  • Library/Analysis/PTKComputeEmphysemaFromMask.m - estimate the percentage of emphysema using a simple threshoding
  • Library/Airways/PTKGetWallThicknessForBranch.m - estimate airway radius and wall thickness for the first airway bronchus in the region being analysed

@yahale
Copy link

yahale commented Oct 21, 2024

Thanks @tomdoel. Will check them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants