Skip to content

Commit

Permalink
ENH: Shorten color table csv file column names
Browse files Browse the repository at this point in the history
CodingSchemeDesignator -> CodingScheme
AnatomicRegion -> Region

Changing from AnatomicRegion to Region also allows more flexible use of the file format (from microscopy to astronomy).
The codes will tell if it is an anatomical region or something else. When exporting to DICOM and the region code defines an anatomical region, it will written there as "anatomical region", but the csv file format can be more generic.
  • Loading branch information
lassoan committed Jan 12, 2025
1 parent b54c96d commit 75d189a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions Libs/MRML/Core/vtkMRMLColorTableStorageNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ Version: $Revision: 1.6 $
#include <sstream>

const std::vector<std::string> TERMINOLOGY_COLUMN_NAMES = {
"Category_CodingSchemeDesignator", "Category_CodeValue", "Category_CodeMeaning",
"Type_CodingSchemeDesignator", "Type_CodeValue", "Type_CodeMeaning",
"TypeModifier_CodingSchemeDesignator", "TypeModifier_CodeValue", "TypeModifier_CodeMeaning",
"AnatomicRegion_CodingSchemeDesignator", "AnatomicRegion_CodeValue", "AnatomicRegion_CodeMeaning",
"AnatomicRegionModifier_CodingSchemeDesignator", "AnatomicRegionModifier_CodeValue", "AnatomicRegionModifier_CodeMeaning" };
"Category_CodingScheme", "Category_CodeValue", "Category_CodeMeaning",
"Type_CodingScheme", "Type_CodeValue", "Type_CodeMeaning",
"TypeModifier_CodingScheme", "TypeModifier_CodeValue", "TypeModifier_CodeMeaning",
"Region_CodingScheme", "Region_CodeValue", "Region_CodeMeaning",
"RegionModifier_CodingScheme", "RegionModifier_CodeValue", "RegionModifier_CodeMeaning" };

//------------------------------------------------------------------------------
vtkMRMLNodeNewMacro(vtkMRMLColorTableStorageNode);
Expand Down Expand Up @@ -309,7 +309,7 @@ int vtkMRMLColorTableStorageNode::ReadCsvFile(std::string fullFileName, vtkMRMLC
// Define helper function for populating terminology entry IDs
auto GetIndexInEntryForIdType = [](std::string idType)
{
if (idType == "CodingSchemeDesignator") return 0;
if (idType == "CodingScheme") return 0;
else if (idType == "CodeValue") return 1;
else if (idType == "CodeMeaning") return 2;
vtkGenericWarningMacro("vtkMRMLColorTableStorageNode::ReadCsvFile::GetIndexInEntryForIdType: Invalid coded entry ID type" << idType);
Expand Down Expand Up @@ -386,11 +386,11 @@ int vtkMRMLColorTableStorageNode::ReadCsvFile(std::string fullFileName, vtkMRMLC
{
typeModifierComponents[GetIndexInEntryForIdType(columnNameComponents[1])] = column->GetValue(row);
}
else if (columnNameComponents[0] == "AnatomicRegion")
else if (columnNameComponents[0] == "Region")
{
anatomicRegionComponents[GetIndexInEntryForIdType(columnNameComponents[1])] = column->GetValue(row);
}
else if (columnNameComponents[0] == "AnatomicRegionModifier")
else if (columnNameComponents[0] == "RegionModifier")
{
anatomicRegionModifierComponents[GetIndexInEntryForIdType(columnNameComponents[1])] = column->GetValue(row);
}
Expand Down Expand Up @@ -550,7 +550,8 @@ int vtkMRMLColorTableStorageNode::ReadCtblFile(std::string fullFileName, vtkMRML
size_t firstnottick = name.find_first_not_of("'");
size_t lastnottick = name.find_last_not_of("'");
std::string withoutTicks = name.substr(firstnottick, (lastnottick - firstnottick) + 1);
vtkDebugMacro("ReadDataInternal: Found ticks around name \"" << name << "\", using name without ticks instead: \"" << withoutTicks << "\"");
vtkDebugMacro("ReadDataInternal: Single quotation marks around name \"" << name
<< "\", using name without quotation marks instead: \"" << withoutTicks << "\"");
name = withoutTicks;
}
if (i < 10)
Expand Down Expand Up @@ -694,7 +695,7 @@ int vtkMRMLColorTableStorageNode::WriteCsvFile(std::string fullFileName, vtkMRML
{
terminologyArrays[idx]->SetValue(rowIndex, terminologyEntry->GetCodeValue());
}
else if (columnName.substr(columnName.size() - 22, 22) == "CodingSchemeDesignator")
else if (columnName.substr(columnName.size() - 12, 12) == "CodingScheme")
{
terminologyArrays[idx]->SetValue(rowIndex, terminologyEntry->GetCodingSchemeDesignator());
}
Expand Down

0 comments on commit 75d189a

Please sign in to comment.