Пример #1
0
def test_stat3D():
	import samri.plotting.maps as maps

	stat_map = "/usr/share/mouse-brain-atlases/dsurqec_200micron_roi-dr.nii"
	template = "/usr/share/mouse-brain-atlases/dsurqec_40micron_masked.nii"

	maps.stat3D(stat_map,
		template=template,
		save_as="_stat3D.png",
		show_plot=False,
		threshold=0.5,
		threshold_mesh = 0.5,
		)
Пример #2
0
def test_stat3D_mask():
	import samri.plotting.maps as maps

	stat_map = '/usr/share/mouse-brain-templates/dsurqec_200micron_roi-dr.nii'
	template = '/usr/share/mouse-brain-templates/dsurqec_40micron_masked.nii'

	maps.stat3D(stat_map,
		template=template,
		save_as="_stat3D_mask.png",
		show_plot=False,
		threshold=0.5,
		threshold_mesh = 0.5,
		)
Пример #3
0
def test_stat3D_heatmap():
	import samri.plotting.maps as maps

	bindata_dir = '/usr/share/samri_bidsdata'
	heatmap_image = '{}/l1/sub-4007/ses-ofM/sub-4007_ses-ofM_task-JogB_acq-EPIlowcov_run-1_cbv_tstat.nii.gz'.format(bindata_dir)
	template = '/usr/share/mouse-brain-templates/dsurqec_40micron_masked.nii'

	maps.stat3D(heatmap_image,
		cut_coords=(0.0,-4.6,-3.4),
		template=template,
		save_as="_stat3D_heatmap.png",
		show_plot=False,
		threshold=4,
		threshold_mesh=4,
		)
Пример #4
0
def test_stat3D_overlay():
	"""No explicit `threshold_mesh` specification, in order to test implicit behaviour."""
	import samri.plotting.maps as maps

	bindata_dir = '/usr/share/samri_bidsdata'
	heatmap_image = '{}/l1/sub-4007/ses-ofM/sub-4007_ses-ofM_task-JogB_acq-EPIlowcov_run-1_cbv_tstat.nii.gz'.format(bindata_dir)
	overlay = '/usr/share/mouse-brain-templates/dsurqec_200micron_roi-dr.nii'
	template = '/usr/share/mouse-brain-templates/dsurqec_40micron_masked.nii'

	maps.stat3D(heatmap_image,
		cut_coords=(0.0,-4.6,-3.4),
		overlays=[overlay],
		template=template,
		save_as="_stat3D_overlay.png",
		show_plot=False,
		threshold=4,
		)
Пример #5
0
def plot_results(stat_map,results,hits = 3, template = "/usr/share/mouse-brain-atlases/ambmc2dsurqec_15micron_masked.obj",comparison='gene',vs = "expression",path_to_genes="usr/share/ABI-expression-data",percentile_threshold=94):
	"""
	Plots the input feature map as well as the top three scores

	Parameters:
	stat_map: str
		path to the input feature map NIfTI file
	results: list
		sorted results of the similarity analyis
	template: str
		brain template .obj file to be used for 3D visualization
	percentile_threshold: int, optional
		percentile to determine the treshold used for displaying the feature maps
	path_to_genes: str
		path to folder of ABI-expression-library
	

	"""
	# TODO: put into stat3D or stat, to avoid loading the data twice threshold = fast_abs_percentile(stat_map)
	dis = dict()
	img_s = nibabel.load(stat_map)
	img_data_s = img_s.get_fdata()
	tresh_s = fast_abs_percentile(img_data_s[img_data_s >0],percentile=percentile_threshold)
	print(tresh_s)
	display_stat = maps.stat3D(stat_map,template="/usr/share/mouse-brain-atlases/dsurqec_200micron_masked.nii",save_as= '_stat.png',threshold=tresh_s,positive_only=True,figure_title=os.path.basename(stat_map))
	dis["main"] = display_stat
	for i in range(0,hits):
		gene_name = results[i][0].split("_")[0] #TODO:this should work in both cases (also for connectivity??)
		full_path_to_gene = results[i][1][1]  #TODO what ??????
		print("now plotting: ")
		print(full_path_to_gene)
		img = nibabel.load(full_path_to_gene)
		img_data = img.get_fdata()
		tresh = fast_abs_percentile(img_data[img_data > 0],percentile=98)
		display = maps.stat3D(full_path_to_gene,template="/usr/share/mouse-brain-atlases/dsurqec_200micron_masked.nii",save_as=str(i) + '.png',threshold=tresh,positive_only=True,figure_title=gene_name)
		dis[str(i)] = display
	_plot(dis,stat_map,vs)
	print(tresh_s)
	print(tresh)
	#TODO:sep.function?

	return