Repository: mne-tools/mne-python

Issue:
anonymize also sex and hand
anonymize with keep_his False keeps what's in: `raw.info['subject_info']`
which contains hand and sex for example.

Should we remove these info with keep_his=False or should we introduce another parameter?


Discussion:
What does "his" mean?
Thoughts @bloyl ?
HIS = health information system

On Wed, Aug 19, 2020 at 2:09 PM Eric Larson <notifications@github.com>
wrote:

> Thoughts @bloyl <https://github.com/bloyl> ?
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/mne-tools/mne-python/issues/8130#issuecomment-676243742>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AABHKHGHSJNJFEJMPY7G3KDSBO6ILANCNFSM4QE2PVOQ>
> .
>

I don't think that handedness and sex/gender are considered PHI or
Identifing information in the US.

That being said I would remove them if `keep_his=False` to not further
complicate the API.

In general I feel like depending on the fif files to hold this type of
information is error prone and probably unreliable particularly across
sites.



On Wed, Aug 19, 2020 at 8:51 AM Alexandre Gramfort <notifications@github.com>
wrote:

> HIS = health information system
>
> On Wed, Aug 19, 2020 at 2:09 PM Eric Larson <notifications@github.com>
> wrote:
>
> > Thoughts @bloyl <https://github.com/bloyl> ?
> >
> > —
> > You are receiving this because you authored the thread.
> > Reply to this email directly, view it on GitHub
> > <
> https://github.com/mne-tools/mne-python/issues/8130#issuecomment-676243742
> >,
> > or unsubscribe
> > <
> https://github.com/notifications/unsubscribe-auth/AABHKHGHSJNJFEJMPY7G3KDSBO6ILANCNFSM4QE2PVOQ
> >
> > .
> >
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/mne-tools/mne-python/issues/8130#issuecomment-676301957>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABKTXHIQ3W7ELVZL52V44T3SBPDDXANCNFSM4QE2PVOQ>
> .
>

I would look at what other software do to be consistent.

I'll take this one

Resolving patch:
diff --git a/mne/io/meas_info.py b/mne/io/meas_info.py
--- a/mne/io/meas_info.py
+++ b/mne/io/meas_info.py
@@ -2225,8 +2225,13 @@ def anonymize_info(info, daysback=None, keep_his=False, verbose=None):
             subject_info['id'] = default_subject_id
         if keep_his:
             logger.info('Not fully anonymizing info - keeping \'his_id\'')
-        elif subject_info.get('his_id') is not None:
-            subject_info['his_id'] = str(default_subject_id)
+        else:
+            if subject_info.get('his_id') is not None:
+                subject_info['his_id'] = str(default_subject_id)
+            if subject_info.get('sex') is not None:
+                subject_info['sex'] = default_str
+            if subject_info.get('hand') is not None:
+                subject_info['hand'] = default_str
 
         for key in ('last_name', 'first_name', 'middle_name'):
             if subject_info.get(key) is not None:


Test patch:
diff --git a/mne/io/tests/test_meas_info.py b/mne/io/tests/test_meas_info.py
--- a/mne/io/tests/test_meas_info.py
+++ b/mne/io/tests/test_meas_info.py
@@ -540,6 +540,9 @@ def _test_anonymize_info(base_info):
     exp_info['subject_info']['last_name'] = default_str
     exp_info['subject_info']['id'] = default_subject_id
     exp_info['subject_info']['his_id'] = str(default_subject_id)
+    exp_info['subject_info']['sex'] = default_str
+    exp_info['subject_info']['hand'] = default_str
+
     # this bday is 3653 days different. the change in day is due to a
     # different number of leap days between 1987 and 1977 than between
     # 2010 and 2000.
@@ -564,6 +567,8 @@ def _test_anonymize_info(base_info):
     # exp 2 tests the keep_his option
     exp_info_2 = exp_info.copy()
     exp_info_2['subject_info']['his_id'] = 'foobar'
+    exp_info_2['subject_info']['sex'] = 0
+    exp_info_2['subject_info']['hand'] = 1
 
     # exp 3 tests is a supplied daysback
     delta_t_2 = timedelta(days=43)