Skip to content

Conversation

@Baharis
Copy link
Member

@Baharis Baharis commented Jan 12, 2026

Introduction

This PR constitutes a major rework of the original instamatic-tecnai-server, adding multiple new capabilities and features including new FEI hardware hooks in the interface, new camera support, separate camera server, improvements to the simulated TEM/CAM, handling of generators including movies (see Instamatic PR #154), addition of over 50 tests, addition of new config handling tools and config files. Some of the changes introduced requires polish (e.g. the tests were written for the old single-server design), but in overall this patch "doubles" the range of machines handled by this code. I believe in future it may be a good idea to expand this library further to allow for bare-bones Jeol microscope support, as suggested by @magnunor in instamatic issue #152.

Major changes

  • camera: Added new server and interface for communicating with an FEI-scripting-accessible camera;
  • tests: Added 56 detailed tests for socket communication, TEM interfacing, and camera integration;
  • structure: start.bat, tem_server.py, cam_server.py, tests.py use instamaticServer as a module;

Minor changes

  • calibration: added/renamed config files for TEM (simulate_tem, titan) and cam (simulated cam, ultrascan);
  • config: renamed, slightly reworked Config class to behave more similarly to its instamatic counterpart;
  • generators: in line with instamatic#154, servers now properly handle generators such as get_movie;
  • logging: replaced prints; TEM and cam log to separate files; cam does not log eval to avoid spam;
  • remote_movie.py: new RemoteMovie lazy image generator (FEI camera works on a single thread only);
  • settings.yaml: simplified by removing unused settings
  • simu_camera.py: added a rough simulated camera implementation to allow testing on cam-less setup;
  • simu_microscope.py: extended range of supported methods, aligned with tecnai TEM and its tests;
  • utils/singleton.py: extracted Singleton class now used in many places from tecnai_microscope.py;

Bugfixes

  • utils/config.py: fixed naming ambiguity and repeated (six times!) initialization.

Documentation and code maintenance

  • typing: in new files, added some class typing hints using Python3.4 syntax (a = None # type: int);
  • README.md: adapted and expanded package description and documentation of its features;
  • venv: In case venv misbehaves, added start.bat help and commented boilerplate to elevate the issue;
  • utils/config.py: config class renamed to Config, now init. once as config, replacing many _confs;
  • tecnai_microscope.py: removed a bunch of comments repeated in calibration files' content;
  • types.py: renamed from typing.py to avoid import issue (see Instamatic #114 bug 2 discussion).

I might be missing something but this is the general gist of it. This rework enables the server to interface an FEI Titan microscope (in addition to FEI Tecnai) and an FEI-Scripting-accessible camera. Funny enough, on the setup where this code was developed, the camera was handled by DM, DM accessed by FEI-Scripting, and I could only access the FEI layer. Some more context on the whole endeavour is available here.

Baharis and others added 24 commits November 25, 2025 20:19
@Baharis Baharis requested a review from stefsmeets January 12, 2026 20:00
@Baharis Baharis self-assigned this Jan 12, 2026
@Baharis Baharis added bug Something isn't working enhancement New feature or request labels Jan 12, 2026
@Baharis Baharis added the documentation Improvements or additions to documentation label Jan 14, 2026
@Baharis Baharis marked this pull request as ready for review January 14, 2026 17:34
@Baharis
Copy link
Member Author

Baharis commented Jan 15, 2026

I don't think this repo has particularly many followers, but in case someone does follow it and would like to point to any issues or suggest any changes, I'll be waiting until the end of the weekend to merge this into main. From my perspective working on this branch in the last month on both Titan and Tecnai, it constitutes a straight-up upgrade.

@Baharis Baharis merged commit 6ba2d3f into instamatic-dev:main Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants