short question: Is it an issue if I run pydeface twice on the same T1w?
Related short question: Is there a way to check through the command line if a T1w has been defaced or not?
Background: I process a lot of MRI data on a high-performance cluster. For example, I convert DICOMs to BIDS via heudiconv and then run defacing using pydeface. Then I save everything in a DataLad dataset and move on. Here’s the problem: If I do this process iteratively (e.g., because new data came in), I need to know which T1s have already been defaced or I just run pydeface again on all images just to be save. Hence, the questions above.
I know that pydeface attaches a _defaced suffix to the T1 but I need to remove this by explicitly replacing the defaced T1 with the non-defaced one because BIDS doesn’t allow the _defaced` suffix in the T1w filename and I only want to continue with defaced data.
Of course, I could always sync the data to some place (e.g., local computer) to look at the data (which I do anyways, but only later) but, it’s a a bit of a hassle so I wondered if there’s an easier way.
Any hints very much appreciated! Thanks in advance!
I’m fairly certain that running pydeface twice is going to cause some further erosion of the data, and I would not be comfortable doing it without looking at the result, as the registration fit is going to be significantly degraded.
Detecting defaced data is non-trivial, so unfortunately there’s not a good way to do this.
Possibly the best solution would be to add a feature to pydeface to leave a note in the descrip header field, and you can check for that, though it would obviously only work going forward.
Ok, that’s very good to know. Your proposed solution sounds good to me, I will try something along that line. Or I’ll just don’t get distracted between defacing the data and saving them into the dataset and then live by the rule that whatever is committed has been defaced before
Hi @lennart, your question and @effigies comment got me thinking on this issue. I have made up a simple metric to give some idea of a nifti image being masked. You can see some of my thoughts at pydeface issues page and a script for computing this metric here as a github gist. I would be curious to hear your thoughts if you can spare some time on this. It seems to work for me for the datasets I have. Might be a potential future contribution to pydeface.
There were some discussions regarding “deface detection” over at BIDSonym. We originally had mri-deface-detector included in BIDSonym with the idea that it is run at the beginning and the end of the BIDSonym workflow to check if images are already defaced or were defaced properly respectively. However, we never really got it to work… Maybe we can bring that and @ofgulban’s work together? This extends to certain tags that could be applied to de-identified images, potentially via DataLad.
Cheers, Peer
P.S.: this might be the wrong thread to discuss that.