[Dcmlib] [Fwd: [Insight-developers] anonymize DICOM files]

Benoit Regrain benoit.regrain at creatis.insa-lyon.fr
Fri Feb 4 11:54:53 CET 2005


----- Original Message ----- 
From: "Mathieu Malaterre" <mathieu.malaterre at kitware.com>
To: "Mailing list gdcm" <dcmlib at creatis.insa-lyon.fr>
Sent: Friday, February 04, 2005 1:06 AM
Subject: [Dcmlib] [Fwd: [Insight-developers] anonymize DICOM files]


> Je fais suivre un example de la ML ITK.
>
> Il lui manquait la ligne super importante dans gdcm 0.6:
>
>   gdcm::File f(&h);
> f.GetImageData();   //super important
>   f.WriteDcmExplVR(OutputFilename);
>
> Sinon c'est realisable un vrai 'anonymiser' ? C'est a dire ne modifier que 
> l'entete sans essayer de lire/analyser l'image data ? (=a la hexedit).
Normalement oui, une méthode Anonymize (ou un truc du genre, je ne peux
pas regarder la) permet de faire cela... Je ne suis pas sur qu'il y ait 
d'exemple
ou de test la dessus par contre.
JPR pourrait en dire + sur le sujet.

Benoit



>
> Mathieu
>
>
> -------- Original Message --------
> Subject: [Insight-developers] anonymize DICOM files
> Date: Thu, 03 Feb 2005 17:26:17 -0600
> From: Kent Williams <norman-k-williams at uiowa.edu>
> To: insight-developers at itk.org
>
> I have several DICOM data sets that for one reason or another are not
> working properly with the gdcm Dicom reader.  The problems we're having
> aren't a big deal -- and I can deal with it off the list with the GDCM
> guy -- but I need to anonymize the datasets before sending them offsite.
>
> My idea was to write a simple app that anonymizes the header and dumps a
> new file out. gdcm::Header has a function called 'AnonymizeHeader' that
> I copied to blank out the problem fields, but it's not clear to me how
> to read in the whole dicom slice and write it back out along with the
> pixel data -- using GDCM.
>
> What's happening is that it appears the header is getting written out OK
> but the pixel data is not.
>
> Below is the program I wrote -- clearly I'm missing the 'read in the
> data from the input data, attach it to the output file stage.'
>
> I would have used an anonymizer someone else wrote -- if there was one I
> could trust, that was free, and didn't have a stupid user interface!
> Google didn't find anything like that!
>
>
> #include "gdcm.h"
> #include "unistd.h"
>
> int
> main(int argc, char **argv)
> {
>  char *inputfilename(0),
>    *outputfilename(0);
>  int c;
>  bool quitopt = false;
>  while(!quitopt && (c = getopt(argc,argv,"i:o:")) != -1)
>    {
>    switch(c)
>      {
>      case 'i':
>        inputfilename = optarg;
>        break;
>      case 'o':
>        outputfilename = optarg;
>        break;
>      default:
>        quitopt = true;
>        break;
>      }
>    }
>  if(inputfilename == 0)
>    {
>    std::cerr << "No input file given" << std::endl;
>    exit(-1);
>    }
>  if(outputfilename == 0)
>    {
>    std::cerr << "No output file given" << std::endl;
>    exit(-1);
>    }
>  std::string InputFilename(inputfilename),
>    OutputFilename(outputfilename);
>
>  gdcm::Header h(InputFilename);
>  if(!h.IsReadable())
>    {
>    std::cerr << "Can't open input file " << inputfilename << std::endl;
>    exit(-1);
>    }
>   // If exist, replace by spaces
>   h.SetEntryByNumber ("  ",0x0010, 0x2154); // Telephone
>   h.SetEntryByNumber ("  ",0x0010, 0x1040); // Adress
>   h.SetEntryByNumber ("  ",0x0010, 0x0020); // Patient ID
>
>   gdcm::DocEntry* patientNameHE = h.GetDocEntryByNumber (0x0010, 0x0010);
>
>   if ( patientNameHE ) // we replace it with bogus name
>     {
>     h.ReplaceOrCreateByNumber("Ernest_T_Bass", 0x0010, 0x0010);
>     }
>   gdcm::File f(&h);
>   f.WriteDcmExplVR(OutputFilename);
> }
>
> _______________________________________________
> Insight-developers mailing list
> Insight-developers at itk.org
> http://www.itk.org/mailman/listinfo/insight-developers
>
> _______________________________________________
> Dcmlib mailing list
> Dcmlib at creatis.insa-lyon.fr
> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib 




More information about the Dcmlib mailing list