Beispiel #1
0
def dr_seed_fc():
	import numpy as np
	from os import path
	from labbookdb.report.tracking import treatment_group, append_external_identifiers
	from samri.plotting.overview import multiplot_matrix, multipage_plot
	from samri.utilities import bids_substitution_iterator
	from samri.analysis import fc

	db_path = '~/syncdata/meta.db'
	groups = treatment_group(db_path, ['cFluDW','cFluDW_'], 'cage')
	groups = append_external_identifiers(db_path, groups, ['Genotype_code'])
	all_subjects = groups['ETH/AIC'].unique()

	substitutions = bids_substitution_iterator(
		["ofM","ofMaF","ofMcF1","ofMcF2","ofMpF"],
		all_subjects,
		["CogB",],
		"~/ni_data/ofM.dr/",
		"composite",
		acquisitions=["EPI",],
		check_file_format='~/ni_data/ofM.dr/preprocessing/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv.nii.gz')

	fc_results = fc.seed_based(substitutions, "~/ni_data/templates/roi/DSURQEc_dr.nii.gz", '/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii',
		ts_file_template='~/ni_data/ofM.dr/preprocessing/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv.nii.gz',
		save_results="~/ni_data/ofM.dr/fc/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv_zstat.nii.gz",
		)
Beispiel #2
0
def dr_seed_fc():
	import numpy as np
	from os import path
	from labbookdb.report.tracking import treatment_group, append_external_identifiers
	from samri.plotting.overview import multiplot_matrix, multipage_plot
	from samri.utilities import bids_substitution_iterator
	from samri.analysis import fc

	db_path = '~/syncdata/meta.db'
	groups = treatment_group(db_path, ['cFluDW','cFluDW_'], 'cage')
	groups = append_external_identifiers(db_path, groups, ['Genotype_code'])
	all_subjects = groups['ETH/AIC'].unique()

	substitutions = bids_substitution_iterator(
		["ofM","ofMaF","ofMcF1","ofMcF2","ofMpF"],
		all_subjects,
		["CogB",],
		"~/ni_data/ofM.dr/",
		"composite",
		acquisitions=["EPI",],
		check_file_format='~/ni_data/ofM.dr/preprocessing/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv.nii.gz')

	fc_results = fc.seed_based(substitutions, "~/ni_data/templates/roi/DSURQEc_dr.nii.gz", "/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii",
		ts_file_template='~/ni_data/ofM.dr/preprocessing/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv.nii.gz',
		save_results="~/ni_data/ofM.dr/fc/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv_zstat.nii.gz",
		)
Beispiel #3
0
def drp_seed_fc():
    import numpy as np
    from os import path
    #from labbookdb.report.tracking import treatment_group, append_external_identifiers
    from samri.plotting.overview import multiplot_matrix, multipage_plot
    from samri.utilities import bids_substitution_iterator
    from samri.analysis import fc
    from samri.utilities import N_PROCS

    N_PROCS = max(N_PROCS - 8, 2)

    from bids.grabbids import BIDSLayout
    from bids.grabbids import BIDSValidator
    import os

    base = '~/ni_data/ofM.dr/bids/preprocessing/generic/'
    base = os.path.abspath(os.path.expanduser(base))
    validate = BIDSValidator()
    for x in os.walk(base):
        print(x[0])
        print(validate.is_bids(x[0]))
    layout = BIDSLayout(base)
    df = layout.as_data_frame()
    df = df[df.type.isin(['cbv'])]
    print(df)

    #substitutions = bids_substitution_iterator(
    #	list(df['session'].unique()),
    #	all_subjects,
    #	["CogB",],
    #	"~/ni_data/ofM.dr/",
    #	"composite",
    #	acquisitions=["EPI",],
    #	check_file_format='~/ni_data/ofM.dr/preprocessing/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv.nii.gz')

    #substitutions = df.T.to_dict().values()[:2]
    substitutions = df.T.to_dict().values()
    print(substitutions)

    fc_results = fc.seed_based(
        substitutions,
        "~/ni_data/templates/roi/DSURQEc_drp.nii.gz",
        "/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii",
        ts_file_template=
        '~/ni_data/ofM.dr/bids/preprocessing/generic/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv.nii.gz',
        save_results=
        "~/ni_data/ofM.dr/bids/fc/DSURQEc_drp/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv_zstat.nii.gz",
        n_procs=N_PROCS,
        cachedir='/mnt/data/joblib')
Beispiel #4
0
def drp_seed_fc():
	import numpy as np
	from os import path
	#from labbookdb.report.tracking import treatment_group, append_external_identifiers
	from samri.plotting.overview import multiplot_matrix, multipage_plot
	from samri.utilities import bids_substitution_iterator
	from samri.analysis import fc
	from samri.utilities import N_PROCS

	N_PROCS=max(N_PROCS-8, 2)

	from bids.grabbids import BIDSLayout
	from bids.grabbids import BIDSValidator
	import os

	base = '~/ni_data/ofM.dr/bids/preprocessing/generic/'
	base = os.path.abspath(os.path.expanduser(base))
	validate = BIDSValidator()
	for x in os.walk(base):
		print(x[0])
		print(validate.is_bids(x[0]))
	layout = BIDSLayout(base)
	df = layout.as_data_frame()
	df = df[df.type.isin(['cbv'])]
	print(df)

	#substitutions = bids_substitution_iterator(
	#	list(df['session'].unique()),
	#	all_subjects,
	#	["CogB",],
	#	"~/ni_data/ofM.dr/",
	#	"composite",
	#	acquisitions=["EPI",],
	#	check_file_format='~/ni_data/ofM.dr/preprocessing/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv.nii.gz')

	#substitutions = df.T.to_dict().values()[:2]
	substitutions = df.T.to_dict().values()
	print(substitutions)

	fc_results = fc.seed_based(substitutions, "~/ni_data/templates/roi/DSURQEc_drp.nii.gz", "/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii",
		ts_file_template='~/ni_data/ofM.dr/bids/preprocessing/generic/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv.nii.gz',
		save_results="~/ni_data/ofM.dr/bids/fc/DSURQEc_drp/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_acq-{acquisition}_task-{task}_cbv_zstat.nii.gz",
		n_procs=N_PROCS,
		cachedir='/mnt/data/joblib')
Beispiel #5
0
def seed_connectivity_overview(
    template='/usr/share/mouse-brain-atlases/dsurqec_40micron_masked.nii',
    cut_coords=[None, [0, -4.9, -3.3]],
    plot=False,
):
    import numpy as np
    from labbookdb.report.tracking import treatment_group, append_external_identifiers
    from samri.plotting.overview import multiplot_matrix, multipage_plot

    db_path = '~/syncdata/meta.db'
    groups = treatment_group(db_path, ['cFluDW', 'cFluDW_'], 'cage')
    groups = append_external_identifiers(db_path, groups, ['Genotype_code'])
    all_subjects = groups['ETH/AIC'].unique()
    treatment = groups[(groups['Genotype_code'] == "eptg")
                       & (groups['Cage_TreatmentProtocol_code'] == "cFluDW"
                          )]['ETH/AIC'].tolist()
    no_treatment = groups[(groups['Genotype_code'] == "eptg")
                          & (groups['Cage_TreatmentProtocol_code'] == "cFluDW_"
                             )]['ETH/AIC'].tolist()
    negative_controls = groups[groups['Genotype_code'] ==
                               "epwt"]['ETH/AIC'].tolist()
    print(treatment, no_treatment, negative_controls)
    substitutions = bids_substitution_iterator(
        ["ofM", "ofM_aF", "ofM_cF1", "ofM_cF2", "ofM_pF"],
        all_subjects,
        [
            "EPI_CBV_chr_longSOA",
        ],
        "~/ni_data/ofM.dr/",
        "composite",
    )
    fc_results = fc.seed_based(
        substitutions,
        "~/ni_data/templates/roi/DSURQEc_dr_xs.nii.gz",
        '/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii',
        ts_file_template=
        "~/ni_data/ofM.dr/preprocessing/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_task-{task}.nii.gz",
    )

    print([i['subject'] for i in fc_results])
    return
    if plot:
        multipage_plot(
            fc_results,
            treatment,
            figure_title="Chronic Fluoxetine (drinking water) Treatment Group",
            template=template,
            threshold=0.1,
            base_cut_coords=cut_coords,
            save_as="fc_treatment.pdf",
            overlays=['~/ni_data/templates/roi/DSURQEc_dr_xs.nii.gz'],
            scale=0.4,
        )
        multipage_plot(
            fc_results,
            no_treatment,
            figure_title="Chronic Fluoxetine (drinking water) Treatment Group",
            template=template,
            threshold=0.1,
            base_cut_coords=cut_coords,
            save_as="fc_no_treatment.pdf",
            overlays=['~/ni_data/templates/roi/DSURQEc_dr_xs.nii.gz'],
            scale=0.4,
        )
        multipage_plot(
            fc_results,
            negative_controls,
            figure_title="Chronic Fluoxetine (drinking water) Treatment Group",
            template=template,
            threshold=0.1,
            base_cut_coords=cut_coords,
            save_as="fc_negative_control.pdf",
            overlays=['~/ni_data/templates/roi/DSURQEc_dr_xs.nii.gz'],
            scale=0.4,
        )
Beispiel #6
0
def seed_connectivity_overview(
	template="/usr/share/mouse-brain-atlases/dsurqec_40micron_masked.nii",
	cut_coords=[None,[0,-4.9,-3.3]],
	plot=False,
	):
	import numpy as np
	from labbookdb.report.tracking import treatment_group, append_external_identifiers
	from samri.plotting.overview import multiplot_matrix, multipage_plot

	db_path = '~/syncdata/meta.db'
	groups = treatment_group(db_path, ['cFluDW','cFluDW_'], 'cage')
	groups = append_external_identifiers(db_path, groups, ['Genotype_code'])
	all_subjects = groups['ETH/AIC'].unique()
	treatment = groups[
			(groups['Genotype_code']=="eptg")&
			(groups['Cage_TreatmentProtocol_code']=="cFluDW")
			]['ETH/AIC'].tolist()
	no_treatment = groups[
			(groups['Genotype_code']=="eptg")&
			(groups['Cage_TreatmentProtocol_code']=="cFluDW_")
			]['ETH/AIC'].tolist()
	negative_controls = groups[groups['Genotype_code']=="epwt"]['ETH/AIC'].tolist()
	print(treatment, no_treatment, negative_controls)
	substitutions = bids_substitution_iterator(
		["ofM","ofM_aF","ofM_cF1","ofM_cF2","ofM_pF"],
		all_subjects,
		["EPI_CBV_chr_longSOA",],
		"~/ni_data/ofM.dr/",
		"composite",
		)
	fc_results = fc.seed_based(substitutions, "~/ni_data/templates/roi/DSURQEc_dr_xs.nii.gz", "/usr/share/mouse-brain-atlases/dsurqec_200micron_mask.nii",
		ts_file_template="~/ni_data/ofM.dr/preprocessing/{preprocessing_dir}/sub-{subject}/ses-{session}/func/sub-{subject}_ses-{session}_task-{task}.nii.gz",
		)

	print([i['subject'] for i in fc_results])
	return
	if plot:
		multipage_plot(fc_results, treatment,
			figure_title="Chronic Fluoxetine (drinking water) Treatment Group",
			template=template,
			threshold=0.1,
			base_cut_coords=cut_coords,
			save_as="fc_treatment.pdf",
			overlays=['~/ni_data/templates/roi/DSURQEc_dr_xs.nii.gz'],
			scale=0.4,
			)
		multipage_plot(fc_results, no_treatment,
			figure_title="Chronic Fluoxetine (drinking water) Treatment Group",
			template=template,
			threshold=0.1,
			base_cut_coords=cut_coords,
			save_as="fc_no_treatment.pdf",
			overlays=['~/ni_data/templates/roi/DSURQEc_dr_xs.nii.gz'],
			scale=0.4,
			)
		multipage_plot(fc_results, negative_controls,
			figure_title="Chronic Fluoxetine (drinking water) Treatment Group",
			template=template,
			threshold=0.1,
			base_cut_coords=cut_coords,
			save_as="fc_negative_control.pdf",
			overlays=['~/ni_data/templates/roi/DSURQEc_dr_xs.nii.gz'],
			scale=0.4,
			)