Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision da9badeb9444052b558b6b134b72df5fff0fc277 authored by liangzifei on 09 March 2022, 23:29:32 UTC, committed by GitHub on 09 March 2022, 23:29:32 UTC
Update README.md
1 parent f116deb
  • Files
  • Changes
  • 0360b4c
  • /
  • Code
  • /
  • MRH_testingPrep.m
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:da9badeb9444052b558b6b134b72df5fff0fc277
directory badge
swh:1:dir:699a1ad78753f130bee0affcc069dad78b04ec02
content badge
swh:1:cnt:91401f9e22e4aaf984066ad83cfb79821058295e

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
MRH_testingPrep.m
%  Testing data generation
%  The data is prepared from inital analyzed format dMRI data and saved in .mat file.

% Input:
%
% foder_dwi: the location of dmri analyzed image.
% ---default=work_folder = ['.\Test_Data'];
%halfsize_input : the patchsize preparison paramter.
%--- default=1 means the pathsize is 2*1+1 = 3
% stride: the sample location of the training coordinates within a 3D brain
% grids. --- default =1 means sample each specific pixels among the entire
% brain.
% slice_num_start, slice_num_end: start and end slices to be tested.
% By default, only one slice is tested.
%
% Output(saved file):
%
% data: is a 3x3xMxN matrix that for nerual network input.
% label: is a 3x3xN matrix that for neurual network training target.
%
% Usage: [data,label] = MRH_trainingG(['R:\zhangj18lab\zhangj18labspace\'...
%'Zifei_Data\HCP\DeepNetIdea\JesseGray\JesseGray20191223\Porcessed\C'],...
%3,20)

%  - Zifei Liang (zifei.liang@nyumc.org)

% Using code please refer our work:
% Inferring Maps of Cellular Structures from MRI Signals using Deep Learning
% https://www.biorxiv.org/content/10.1101/2020.05.01.072561v1

function [data,fa] = MRH_testingPrep(folder_dwi, halfsize_input, stride,sample_num,slice_num_start, slice_num_end)
folder_list=dir(folder_dwi); folder_list(1:2) = [];
% count the test samples amount. 
count=0;
for sample_img =sample_num:sample_num%length(file_list)
    % load all MRI images.
    dwi2000 = load_untouch_nii([folder_dwi,folder_list(sample_num).name,'\rigidaffine_Lddm_dwi2000.img']);
    dwi5000 = load_untouch_nii([folder_dwi,folder_list(sample_num).name,'\rigidaffine_Lddm_dwi5000.img']);
    t2MTONOFF = load_untouch_nii([folder_dwi,folder_list(sample_num).name,'\rigidaffine_lddm_t2MTONOFF.img']);
    fa_img = load_untouch_nii([folder_dwi,folder_list(sample_num).name,'\rigidaffine_Lddm_fa.img']);
    fa_mask = load_untouch_nii([folder_dwi,folder_list(sample_num).name,'\Masked_outline.img']);
    %     axon_img = load_untouch_nii(['R:\zhangj18lab\zhangj18labspace\Zifei_Data\HCP\DeepNetIdea\',...
    %         'JesseGray\JesseGray20191223\Porcessed\Axon_to_C',num2str(sample_img),'.img']);
    
    %% data pre-process %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    dwi_data = cat(4,dwi2000.img,dwi5000.img,t2MTONOFF.img);
    fa_data=fa_img.img; fa_data(isnan(fa_data))=0; dwi_data(isnan(dwi_data))=0;
    mask_data = fa_mask.img; mask_data(isnan(mask_data))=0;
    %     ns_data = axon_img.img; ns_data(isnan(ns_data))=0;
    
    dwi_data=permute(dwi_data,[1,3,2,4]); fa_data=permute(fa_data,[1,3,2]);
    mask_data = 1- permute(mask_data,[1,3,2]); %ns_data = permute(ns_data,[1,3,2]);
    
    dwi_data=double(dwi_data);%./double(max(max(max(max(max(dwi_data))))));
    fa_data=double(fa_data);%./double(max(max(max(max(max(fa_data))))));
    
    [A,B,C,D]=size(dwi_data);
    %     figure;subplot(1,2,1);imshow(ns_data(:,:,124),[]); subplot(1,2,2);imshow(fa_data(:,:,124),[]);
    %clear dwi_img fa_img;
    [hei,wid,C,channel]=size(dwi_data);
    %% loop count samples %%%%%%%%%%%%%%%%%%%%%%%%%
    %     for slice=1:228
    for slice=slice_num_start:slice_num_end
        %         seg_slice=seg_P60data(:,:,slice);
        for x = 1+halfsize_input : stride : hei-halfsize_input
            for y = 1+halfsize_input :stride : wid-halfsize_input
                subim_input = dwi_data(x-halfsize_input : x+halfsize_input, y-halfsize_input : y+halfsize_input,slice,[1:end]);
                %                 subim_label = ns_data(x-halfsize_input : x+halfsize_input, y-halfsize_input : y+halfsize_input,slice);
                subim_fa = fa_data(x-halfsize_input : x+halfsize_input, y-halfsize_input : y+halfsize_input,slice);
                count=count+1
                data(:, :, :, count) = permute(subim_input,[1,2,4,3]);
                fa(:, :, :, count) = subim_fa;
            end
        end
    end
end
% save testing patches in mat file.
save  testdataPatch_mouse.mat data fa -v7.3;
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API