Mercurial > repos > jcb-mpl > orbi_h5_to_dat
comparison src/mz_sci2hdf5.sci @ 0:03c9a3b59377 draft
Uploaded
author | jcb-mpl |
---|---|
date | Mon, 26 Apr 2021 16:28:21 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:03c9a3b59377 |
---|---|
1 function res_out=mz_sci2hdf5(res,h5name) | |
2 | |
3 // entrees: ------------------------- | |
4 // res: une structure avec les champs .time et .mzdata | |
5 | |
6 // sorties: | |
7 // newname2: le nom du fichier de sortie, au format .h5 | |
8 // avec les champs: | |
9 // ChromatogramIndex | |
10 // ChomatogramTime | |
11 // SpectrumIntensity | |
12 // SpectrumMZ | |
13 // SpectrumIndex | |
14 | |
15 // preparer les donnes .dat au format .h5 | |
16 // load(filedat_in) // donne res.time et res.bary | |
17 | |
18 n=length(res.time); | |
19 | |
20 ChromatogramIndex=n; | |
21 | |
22 ChomatogramTime=res.time; | |
23 | |
24 SpectrumIntensity=[]; | |
25 SpectrumMZ=[]; | |
26 SpectrumIndex=[]; | |
27 | |
28 for i=1:n; | |
29 mz_i=res.mzdata(i); // une matrice de 2 colonnes | |
30 diff_i=mz_i(2:$,1)-mz_i(1:$-1,1); | |
31 if i==1 then | |
32 SpectrumIntensity=mz_i(:,2); | |
33 SpectrumMZ=[mz_i(1,1); diff_i]; | |
34 SpectrumIndex=size(mz_i,1); | |
35 else | |
36 SpectrumIntensity=[SpectrumIntensity; mz_i(:,2)]; | |
37 SpectrumMZ=[SpectrumMZ; mz_i(1,1); diff_i]; | |
38 SpectrumIndex=[SpectrumIndex;SpectrumIndex($)+size(mz_i,1)]; | |
39 end | |
40 end | |
41 | |
42 // on a reconstitue les champs au format h5 | |
43 | |
44 b=h5open(h5name,"w"); | |
45 h5write(b,"ChromatogramIndex",ChromatogramIndex); | |
46 h5write(b,"ChomatogramTime",ChomatogramTime'); | |
47 h5write(b,"SpectrumIntensity",SpectrumIntensity'); | |
48 h5write(b,"SpectrumMZ",SpectrumMZ'); | |
49 h5write(b,"SpectrumIndex",SpectrumIndex'); | |
50 h5close(b) | |
51 | |
52 res_out=1; | |
53 | |
54 endfunction |