pydicom.fileset.DIRECTORY_RECORDERS = {'ASSESSMENT': <function _define_assessment>, 'ENCAP DOC': <function _define_encap_doc>, 'FIDUCIAL': <function _define_generic_content_id>, 'HANGING PROTOCOL': <function _define_hanging_protocol>, 'IMAGE': <function _define_image>, 'IMPLANT': <function _define_implant>, 'IMPLANT ASSY': <function _define_implant_assy>, 'IMPLANT GROUP': <function _define_implant_group>, 'KEY OBJECT DOC': <function _define_key_object_doc>, 'MEASUREMENT': <function _define_generic_content_id>, 'PALETTE': <function _define_palette>, 'PATIENT': <function _define_patient>, 'PLAN': <function _define_empty>, 'PRESENTATION': <function _define_presentation>, 'RADIOTHERAPY': <function _define_radiotherapy>, 'RAW DATA': <function _define_generic_content>, 'REGISTRATION': <function _define_generic_content_id>, 'RT DOSE': <function _define_rt_dose>, 'RT PLAN': <function _define_rt_plan>, 'RT STRUCTURE SET': <function _define_rt_structure_set>, 'RT TREAT RECORD': <function _define_rt_treatment_record>, 'SERIES': <function _define_series>, 'SPECTROSCOPY': <function _define_spectroscopy>, 'SR DOCUMENT': <function _define_sr_document>, 'STEREOMETRIC': <function _define_empty>, 'STUDY': <function _define_study>, 'SURFACE': <function _define_generic_content_id>, 'SURFACE SCAN': <function _define_surface_scan>, 'TRACT': <function _define_generic_content_id>, 'VALUE MAP': <function _define_generic_content_id>, 'WAVEFORM': <function _define_generic_content>}

A dict containing the directory record creation functions.

The functions are used to create non-PRIVATE records for a given SOP Instance as {"RECORD TYPE": callable}, where "RECORD TYPE" should match one of the allowable values - except PRIVATE - for (0004,1430) Directory Record Type. By overriding the function for a given record type you can customize the directory records that will be included in the DICOMDIR file.


from pydicom.fileset import DIRECTORY_RECORDERS, FileSet

def my_recorder(ds: Dataset) -> Dataset:
    record = Dataset()
    record.OffsetOfTheNextDirectoryRecord = 0
    record.RecordInUseFlag = 0xFFFF
    record.OffsetOfReferencedLowerLevelDirectoryEntity = 0
    record.DirectoryRecordType = "PATIENT"
    if "SpecificCharacterSet" in ds:
        record.SpecificCharacterSet = ds.SpecificCharacterSet

    record.PatientName = ds.get("PatientName")
    record.PatientID = ds.PatientID

    return record


# Use the updated directory recorder
fs = FileSet()

The function should take a single parameter which is the SOP Instance to be added to the File-set as a Dataset and return a Dataset with a single directory record matching the directory record type. See Annex F.3.2.2 for possible record types.

For PRIVATE records you must use the add_custom() method instead.