Skip to content

Commit 87ad7ad

Browse files
authored
Unify iterating over items, fix ts_template_match & threshold_picks bugs (#351)
2 parents 999e00d + 101d896 commit 87ad7ad

19 files changed

+324
-313
lines changed

EstimateWeights/EstimateWeights.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<OutputType>Exe</OutputType>
55
<Version>2.0.0</Version>
66
<AssemblyVersion>2.0.0</AssemblyVersion>
7+
<PublishSingleFile>true</PublishSingleFile>
78
</PropertyGroup>
89
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
910
<OutputPath>..\bin\</OutputPath>

Warp/MainWindow.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2286,7 +2286,7 @@ private void UpdateStatsStatus()
22862286

22872287
try
22882288
{
2289-
JsonArray ItemsJson = new JsonArray(Items.Select(m => m.ToMiniJson(Options.Filter.ParticlesSuffix)).ToArray());
2289+
JsonArray ItemsJson = new JsonArray(Items.Select(m => m.ToMiniJson()).ToArray());
22902290
File.WriteAllText(Path.Join(Options.Import.ProcessingOrDataFolder, "items.json"), ItemsJson.ToJsonString(new JsonSerializerOptions() { WriteIndented = true }));
22912291
}
22922292
catch { }

WarpLib/Movie/Movie.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,7 +2337,7 @@ public virtual int[] GetRelevantImageSizes(int fullSize, float weightingThreshol
23372337
return Result;
23382338
}
23392339

2340-
public JsonNode ToMiniJson(string particleSuffix)
2340+
public virtual JsonNode ToMiniJson(string particleSuffix = null)
23412341
{
23422342
JsonNode Json = new JsonObject();
23432343

@@ -2364,15 +2364,15 @@ public JsonNode ToMiniJson(string particleSuffix)
23642364
Json["AsY"] = CTF == null ? null : MathF.Round(MathF.Sin((float)CTF.DefocusAngle * 2 * Helper.ToRad) * (float)CTF.DefocusDelta, 4);
23652365
}
23662366

2367-
// Motion
2368-
Json["Mtn"] = MeanFrameMovement <= 0 ? null : MathF.Round((float)MeanFrameMovement, 2);
2369-
23702367
// 💩 percentage
23712368
Json["Jnk"] = MaskPercentage < 0 ? null : MathF.Round((float)MaskPercentage, 1);
23722369

23732370
// Particle count for given suffix
2374-
int ParticleCount = GetParticleCount(particleSuffix);
2375-
Json["Ptc"] = ParticleCount < 0 ? null : ParticleCount;
2371+
if (particleSuffix != null)
2372+
{
2373+
int ParticleCount = GetParticleCount(particleSuffix);
2374+
Json["Ptc"] = ParticleCount < 0 ? null : ParticleCount;
2375+
}
23762376

23772377
return Json;
23782378
}

WarpLib/TiltSeries/TiltSeries.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.IO;
77
using System.Linq;
88
using System.Text;
9+
using System.Text.Json.Nodes;
910
using System.Threading;
1011
using System.Threading.Tasks;
1112
using System.Windows;
@@ -2325,6 +2326,46 @@ public override void SaveMeta()
23252326
}
23262327
}
23272328

2329+
public override JsonNode ToMiniJson(string particleSuffix = null)
2330+
{
2331+
JsonNode Json = new JsonObject();
2332+
2333+
// Path relative to processing folder, i.e. just the file name
2334+
// Full path to data (including if it's in a nested folder) is stored in XML metadata
2335+
Json["Path"] = Helper.PathToNameWithExtension(Path);
2336+
2337+
// ProcessingStatus enum
2338+
Json["Stat"] = (int)ProcessingStatus;
2339+
2340+
// CTF
2341+
{
2342+
// Defocus
2343+
Json["Def"] = CTF == null ? null : MathF.Round((float)CTF.Defocus, 4);
2344+
2345+
// Phase shift
2346+
Json["Phs"] = CTF == null ? null : MathF.Round((float)CTF.PhaseShift, 2);
2347+
2348+
// Estimated resolution
2349+
Json["Rsn"] = CTFResolutionEstimate <= 0 ? null : MathF.Round((float)CTFResolutionEstimate, 2);
2350+
2351+
// Astigmatism plot X and Y
2352+
Json["AsX"] = CTF == null ? null : MathF.Round(MathF.Cos((float)CTF.DefocusAngle * 2 * Helper.ToRad) * (float)CTF.DefocusDelta, 4);
2353+
Json["AsY"] = CTF == null ? null : MathF.Round(MathF.Sin((float)CTF.DefocusAngle * 2 * Helper.ToRad) * (float)CTF.DefocusDelta, 4);
2354+
}
2355+
2356+
// Tilt count
2357+
Json["Tlts"] = NTilts;
2358+
2359+
// Particle count for given suffix
2360+
if (particleSuffix != null)
2361+
{
2362+
int ParticleCount = GetParticleCount(particleSuffix);
2363+
Json["Ptc"] = ParticleCount < 0 ? null : ParticleCount;
2364+
}
2365+
2366+
return Json;
2367+
}
2368+
23282369
#endregion
23292370

23302371
#region Hashes

0 commit comments

Comments
 (0)