[Dcmlib] AnonymizeNoLoad() (BIS)
Mathieu Malaterre
mathieu.malaterre at kitware.com
Wed Nov 15 20:40:06 CET 2006
Hi Greg,
I am not sure I understand. If a DICOM file is mark read only by the
OS, then gdcm will
- fail to read the file
- fail to report there is a problem ?
Thanks
Mathieu
Greg Book wrote:
> I got it to work. It turns out the files were read-only, in Windows XP.
> Windows doesn't generally complain when you try to access a read only
> file. Maybe gdcm2 could give a message if the file is read-only.
>
> Thanks,
> Greg
>
>
>
> Jean-Pierre Roux wrote:
>> Greg Book wrote:
>>
>>> So, I'm still having this problem... Has anyone seen this problem
>>> before? I'm wondering if it's something I'm doing wrong, or if its a
>>> bug? And, if it is a bug, will it be fixed in version 2.0?
>>>
>> Now, your code looks very much like a copy-paste of
>> Example/AnonymizeNoLoad.cxx, and AnonymizeNoLoad seems bug free ...
>>
>> Here, we use gdcm1.3, but it worked at gdcm1.2 time (there's an API
>> breaking modif between 1.2 and 1.3 : we use a reference counting,
>> therefore, we must write f = gdcm::File::New( );
>> and
>> f->Delete();
>> instead of
>> f = new gdcm::File();
>> and
>> delete f;
>>
>> gdcm2.0 will be something quite different, and was developed by
>> Mathieu, when he has some time left.
>> No date can be anounced for the first gdcm2 'stable release' (Mathieu
>> : any comment?)
>> Could you send me one of your files : I would like to check if there
>> is nothing 'strange' in the header that would break somewhere in gdcm ?
>> Thx
>> Jean-Pierre Roux
>>
>>> Thanks,
>>> Greg
>>>
>>>
>>>
>>> Greg Book wrote:
>>>
>>>> I finally got around to working on it last night. I now have the
>>>> following code, but the dicom file is not anonymized. I put in a
>>>> break point, and the file object has the correct anonymize elements.
>>>>
>>>> f = new gdcm::File();
>>>> f->SetLoadMode(gdcm::LD_ALL);
>>>> f->SetFileName(filelist.Item(i).c_str());
>>>> if (!f->Load()) {
>>>> delete f;
>>>> continue;
>>>> }
>>>>
>>>> f->AddAnonymizeElement( 0x0010, 0x0010, "Non^Person");
>>>>
>>>> f->AnonymizeNoLoad();
>>>> f->ClearAnonymizeList();
>>>> delete f;
>>>>
>>>> -Greg
>>>>
>>>>
>>>>
>>>> Jean-Pierre Roux wrote:
>>>>
>>>>> Greg Book wrote:
>>>>>
>>>>>> I added f->Load(), but still nothing happens. This is on Windows
>>>>>> XP, using gdcm 1.2.2 downloaded from sourceforge. Here is the new
>>>>>> code:
>>>>>>
>>>>>> for (i=0;i<filelist.Count();i++) {
>>>>>> /* open dicom file */
>>>>>> f = new gdcm::File();
>>>>>> f->SetLoadMode(gdcm::LD_ALL);
>>>>>> f->SetFileName(filelist.Item(i).c_str());
>>>>>> /* determine which fields to anonymize */
>>>>>
>>>>>
>>>>>
>>>>> --> I'm not sure of what you want to do here :
>>>>> --> What is chkPatientName?
>>>>> --> When I replace, in your code the following lines by :
>>>>> f->AddAnonymizeElement( 0x0010, 0x0010, "g^Fantomas" );
>>>>> f->AddAnonymizeElement( 0x0010, 0x0030,"11111111" );
>>>>> f->AddAnonymizeElement( 0x0008, 0x0020, "11111111");
>>>>> etc
>>>>> the file is anonymized ?!?
>>>>>
>>>>> Jean-Pierre
>>>>>
>>>>>> if (chkPatientName->GetValue())
>>>>>> f->AddAnonymizeElement( 0x0010, 0x0010,
>>>>>> txtPatientName->GetValue().c_str());
>>>>>> if (chkPatientBirthdate->GetValue())
>>>>>> f->AddAnonymizeElement( 0x0010, 0x0030,
>>>>>> txtPatientBirthdate->GetValue().c_str());
>>>>>> if (chkStudyDate->GetValue())
>>>>>> f->AddAnonymizeElement( 0x0008, 0x0020,
>>>>>> txtStudyDate->GetValue().c_str());
>>>>>> if (chkSeriesDate->GetValue())
>>>>>> f->AddAnonymizeElement( 0x0008, 0x0021,
>>>>>> txtSeriesDate->GetValue().c_str());
>>>>>> if (!f->Load()) {
>>>>>> delete f;
>>>>>> continue;
>>>>>> }
>>>>>> f->AnonymizeNoLoad();
>>>>>> f->ClearAnonymizeList();
>>>>>> /* close the file */
>>>>>> delete f;
>>>>>> }
>>>>>>
>>>>>> -Greg
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Jean-Pierre Roux wrote:
>>>>>>
>>>>>>> Jean-Pierre Roux wrote:
>>>>>>>
>>>>>>>> Greg Book wrote:
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> I'm attempting to anonymize a file using
>>>>>>>>> gdcm::File::AnonymizeNoLoad(). I use the following code, but
>>>>>>>>> the file is not anonymized, the file date is not changed either.
>>>>>>>>> What might be happening?
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>> --> OK : my answer may look strange
>>>>>>> Please use
>>>>>>>
>>>>>>> f->Load()
>>>>>>> juste before using f->AnonymizeNoLoad()
>>>>>>>
>>>>>>> This is not a mistake, just a stupid name for AnonymizeNoLoad :
>>>>>>> NoLoad was *not* "don't load the file header", but "don't load
>>>>>>> the pixels in memory".
>>>>>>> The right name should be : AnonymizeNoGetData
>>>>>>>
>>>>>>>
>>>>>>> Jean-Pierre Roux
>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Greg
>>>>>>>>>
>>>>>>>>> /* open dicom file */
>>>>>>>>> f = new gdcm::File();
>>>>>>>>> f->SetLoadMode(gdcm::LD_ALL);
>>>>>>>>> f->SetFileName(filelist.Item(i).c_str());
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> I'm not on my PC, and I cannot check, but I think you should
>>>>>>>> Load the gdcm::File here.
>>>>>>>>
>>>>>>>> if ( !f->Load() )
>>>>>>>> {
>>>>>>>> std::cout << "[" << fileName << "] is not a
>>>>>>>> gdcm-readable file"
>>>>>>>> << std::endl;
>>>>>>>> f->Delete();
>>>>>>>> return 1;
>>>>>>>> }
>>>>>>>>
>>>>>>>> (Have a look at Example/AnonymizeNoLoad.xx)
>>>>>>>> HTH
>>>>>>>> Jean-Pierre Roux
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>> /* determine which fields to anonymize */
>>>>>>>>> if (chkPatientName->GetValue())
>>>>>>>>> f->AddAnonymizeElement( 0x0010, 0x0010,
>>>>>>>>> txtPatientName->GetValue().c_str());
>>>>>>>>> if (chkPatientBirthdate->GetValue())
>>>>>>>>> f->AddAnonymizeElement( 0x0010, 0x0030,
>>>>>>>>> txtPatientBirthdate->GetValue().c_str());
>>>>>>>>> if (chkStudyDate->GetValue())
>>>>>>>>> f->AddAnonymizeElement( 0x0008, 0x0020,
>>>>>>>>> txtStudyDate->GetValue().c_str());
>>>>>>>>> if (chkSeriesDate->GetValue())
>>>>>>>>> f->AddAnonymizeElement( 0x0008, 0x0021,
>>>>>>>>> txtSeriesDate->GetValue().c_str());
>>>>>>>>> /* close the file */
>>>>>>>>> f->AnonymizeNoLoad();
>>>>>>>>> f->ClearAnonymizeList();
>>>>>>>>> delete f;
>>>>>>>>>
>>>>>>>>> ------------------------------------------------------------------------
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> Dcmlib mailing list
>>>>>>>>> Dcmlib at creatis.insa-lyon.fr
>>>>>>>>> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> Dcmlib mailing list
>>>>>>>> Dcmlib at creatis.insa-lyon.fr
>>>>>>>> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>
>>>>>
>>>>
>>>> ------------------------------------------------------------------------
>>>>
>>>>
>>>> _______________________________________________
>>>> Dcmlib mailing list
>>>> Dcmlib at creatis.insa-lyon.fr
>>>> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
>>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Dcmlib mailing list
>>> Dcmlib at creatis.insa-lyon.fr
>>> http://www.creatis.insa-lyon.fr/mailman/listinfo/dcmlib
>>>
>>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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