1
\$\begingroup\$

I wrote an ad hoc script in Python 3 that calculates where the patient result reside with a specific demographic group within the Turkish population, but until now I stored the data in the python code itself.

The script grew over time, and it seems like it might be a useful tool for researchers from other countries as well. And since the population data for each country differs, storing the reference data in accessible JSON files will make it possible for others to use.

For this purpose I created this reference data structure, but I'm wondering if it could be better and more compact.

What the program uses this data for

  1. Take the name of the test and the number of it to put it on the display list.
  2. Using the demographic data inputted by the user, find the standard deviation and the means of the tests for that group.
  3. Calculate the Z score. (Since Z score = ((test_result - mean)/standard deviation)
  4. Using the Z score, estimate the percentiles, and print and store the results.

The neuropsychiatric test structure

When evaluating test data, we find where the patient score lies within normal distribution, and whether that percentile is considered healthy, or not.

Different factors may affect this (e.g. age, sex, education, race etc.), but not always. So different neuropsychiatric tests might have a different structure. As in, one might be affected by age and sex only, but not education. Another one might be affected by sex, but not age. Also, different tests might have different brackets for age and education, this is why I chose to use a low and high value for each group.

Moreover, different tests might have different number of questions, and some might even not have any distribution data. Some have cut-off values, but not distribution data. This can be easily controlled by adding a bool value (test_has_dist_data = 1/0), and the program will know to use the cutoff value set for the test results, instead of trying to calculate the percentile.

JSON data suggestion

Here's my JSON file condensed (comments are added for code review):

{"test_name" : "mmse", #name of the test to refer in code
 "test_display_name" : "Mini Mental Status Examination" #test name to print
 "test_no" : "1",  #where to put the test in the display list
 "number_of_elements": "3",  #how many questions are in the list
 "element_names": ["question1", "question2", "question3"], #display names of the questions
  "distribution_data": [
  {"gender":"male",
    "age_groups":[
      {"age_low":"0", 
       "age_high":"55", 
       "edu_groups": [
        {"edu_low":"0",
         "edu_high": "5",
         "norm_exists": "1", #whether data exists or not for this demographic group
         "sd_array":["1", "2", "3"], #array to store the standard deviations
         "mean_array": ["111", "222", "333"] #array to store the means
        },
        {"edu_low":"6",
         "edu_high": "11",
         "norm_exists": "1",
         "sd_array":["1", "2", "3"],
         "mean_array": ["111", "222", "333"]
        },
        {"edu_low":"12",
         "edu_high": "999",
         "norm_exists": "1",
         "sd_array":["1", "2", "3"],
         "mean_array": ["111", "222", "333"]
        } 
        ]
      },
      {"age_low":"55",
       "age_high":"69",
       "edu_groups": [
        {"edu_low":"0",
         "edu_high": "5",
         "norm_exists": "1",
         "sd_array":["1", "2", "3"],
         "mean_array": ["111", "222", "333"]
        },
        {"edu_low":"6",
         "edu_high": "11",
         "norm_exists": "1",
         "sd_array":["1", "2", "3"],
         "mean_array": ["111", "222", "333"]
        },
        {"edu_low":"12",
         "edu_high": "999",
         "norm_exists": "1",
         "sd_array":["1", "2", "3"],
         "mean_array": ["111", "222", "333"]
        } 
        ]}

      ]
  }, 

  {"gender":"female"}]

}
\$\endgroup\$
  • 1
    \$\begingroup\$ What does this question specifically to do with python? \$\endgroup\$ – πάντα ῥεῖ Apr 15 '17 at 7:36
  • \$\begingroup\$ Oops. My bad. Removed the tag. \$\endgroup\$ – Bilal 'Cheese' Akbulut Apr 15 '17 at 10:34
  • 1
    \$\begingroup\$ This question currently lacks information. Do the same questions, age brackets, and educational levels apply to every test? Is this JSON being used as a database, or as a response to a query for some subset of the data? \$\endgroup\$ – 200_success Apr 15 '17 at 10:39
  • \$\begingroup\$ @200_success Added the info. Thanks for pointing it out. \$\endgroup\$ – Bilal 'Cheese' Akbulut Apr 16 '17 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.