Monday 12 December 2011

Anonymizing Siemens .rda files

In working towards a useful distribution version with example data files, we need to make sure that all files are de-identified. This script does the trick (matlab):


a=dir('*.rda');
for number=1:size(a)
    a(number).name
    fid = fopen(a(number).name,'r+');
    tline = fgets(fid);
    position=ftell(fid);
    tline = fgets(fid);
    magic=tline;
    size(magic)
    for ii=14:(size(magic,2)-2)
      magic(ii)='*';
    end
    fseek(fid,position,'bof');
    fwrite(fid,magic,'char');
    fclose(fid);
end

No comments:

Post a Comment